题意
给出一个$1-N$的排列$P$,构造两个数组$a, b$满足
Sol
发现我的水平也就是能做一做0-699的题。。。。
直接构造两个等差数列$a, b$,公差为$20000$
然后从小到大枚举$p$,让考前的$a$减去一个较大的数就行了。。
#include<bits/stdc++.h> #define LL long long using namespace std; const int MAXN = 20001, base = 20009; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } int N, a[MAXN], b[MAXN]; int main() { N = read(); for(int i = 1; i <= N; i++) a[i] = base * i; for(int i = 1; i <= N; i++) b[i] = base * (N - i + 1); for(int i = 1; i <= N; i++) { int x = read(); a[x] -= (N - i + 1); } for(int i = 1; i <= N; i++) printf("%d ", a[i]); puts(""); for(int i = 1; i <= N; i++) printf("%d ", b[i]); return 0; }