Submission #47530

#TimeUsernameProblemLanguageResultExecution timeMemory
47530cheater2kCrazy old lady (IZhO13_crazy)C++17
0 / 100
2 ms408 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n; bool taken[N]; int a[N]; int who[N]; void solve() { cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; int cnt = 0; for (int crazy = 1; crazy <= n; ++crazy) { who[1] = crazy; for (int i = 2, cur = 1; i <= n; ++i, ++cur) { if (cur == crazy) ++cur; who[i] = cur; } for (int i = 1; i <= n; ++i) taken[i] = false; taken[a[1]] = true; bool ok = true; for (int i = 2; i <= n; ++i) { if (taken[who[i]]) { if (taken[a[i]]) ok = false; taken[a[i]] = true; } else { if (a[i] != who[i]) ok = false; taken[who[i]] = true; } } cnt += ok; } //cerr << cnt << endl; printf("%d\n", cnt == 1); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while(tt--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...