留坑(p.256)
什么找规律啊 坑爹
1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<algorithm> 5 #include<iostream> 6 7 using namespace std; 8 9 void setIO(const string& s) { 10 freopen((s + ".in").c_str(), "r", stdin); 11 freopen((s + ".out").c_str(), "w", stdout); 12 } 13 template<typename Q> Q read(Q& x) { 14 static char c, f; 15 for(f = 0; c = getchar(), !isdigit(c); ) if(c == '-') f = 1; 16 for(x = 0; isdigit(c); c = getchar()) x = x * 10 + c - '0'; 17 if(f) x = -x; 18 return x; 19 } 20 template<typename Q> Q read() { 21 static Q x; read(x); return x; 22 } 23 24 const int N = 500 + 10; 25 26 int a[N]; 27 28 int main() { 29 #ifdef DEBUG 30 freopen("in.txt", "r", stdin); 31 freopen("out.txt", "w", stdout); 32 #endif 33 34 int T(read<int>()); 35 while(T--) { 36 int n(read<int>()), cnt(0); 37 for(int i = 0; i < n; i++) { 38 read(a[i]); 39 for(int j = 0; j < i; j++) cnt ^= a[i] < a[j]; 40 } 41 if((~n & 1) || !cnt) puts("possible"); 42 else puts("impossible"); 43 } 44 45 return 0; 46 }