题解:P17740 [ICPC 2019 Xuzhou R] Loli, Yen-Jen, and a graph problem
Nuclear_Fish_cyq · · 题解
什么时候才能做出构造题啊。
考虑将大问题递归到小问题。将规模为
我们构造长度为
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ull unsigned long long
#define inf INT_MAX
#define linf LLONG_MAX
#define ninf INT_MIN
#define nlinf LLONG_MIN
#define mod 998244353
#define lwbd lower_bound
#define upbd upper_bound
//#define range
using namespace std;
void read(int &x){
cin >> x;
return;
}
void readll(ll &x){
cin >> x;
return;
}void readdb(db &x){
cin >> x;
return;
}
ll n, cnt, now, p[2005];
void solve(ll qwq){
if(qwq <= 1){
return;
}
solve(qwq - 2);
cnt = 0;
now = qwq - 1;
p[cnt] = now;
for(int i = 1; i <= qwq - 2; i++){
cnt++;
p[cnt] = i;
now = 2 * qwq - 1 - now;
cnt++;
p[cnt] = now;
}
cnt++;
p[cnt] = 2 * qwq - 1 - now;
if(qwq > 2){
for(int i = 0; i <= qwq - 2; i++){
cout << p[i] << " ";
}
cout << endl;
}
for(int i = qwq - 2; i <= 2 * qwq - 3; i++){
cout << p[i] << " ";
}
cout << endl;
return;
}
int main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
solve(n);
return (0 - 0);
}