Submission #47528

#TimeUsernameProblemLanguageResultExecution timeMemory
47528ngkan146Crazy old lady (IZhO13_crazy)C++11
100 / 100
46 ms1236 KiB
#include <bits/stdc++.h> using namespace std; int test, n, a[1005]; int main(){ scanf("%d",&test); while(test--){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); vector <int> ans; for(int oldLady=1;oldLady<=n;oldLady++){ vector <int> peopleId; peopleId.push_back(-1); peopleId.push_back(oldLady); for(int i=1;i<=n;i++) if (i != oldLady) peopleId.push_back(i); //cerr << oldLady << endl; int curSeat = a[1]; bool ok = 1; for(int i=2;i<=n;i++){ //cerr << i << ' ' << curSeat << endl; if (peopleId[i] == curSeat){ curSeat = a[i]; } else{ if (a[i] != peopleId[i]){ ok = 0; break; } } } if (ok) ans.push_back(oldLady); } assert(ans.size()); if (ans.size() > 1) cout << 0 << '\n'; else cout << ans[0] << '\n'; } }

Compilation message (stderr)

crazy.cpp: In function 'int main()':
crazy.cpp:5:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&test);
     ~~~~~^~~~~~~~~~~~
crazy.cpp:7:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&n);
         ~~~~~^~~~~~~~~
crazy.cpp:9:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&a[i]);
             ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...