Submission #100648

#TimeUsernameProblemLanguageResultExecution timeMemory
100648cki86201Crazy old lady (IZhO13_crazy)C++11
100 / 100
12 ms384 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <string> #include <algorithm> #include <iostream> #include <functional> #include <unordered_set> #include <bitset> #include <time.h> #include <limits.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define Fi first #define Se second #define pb(x) push_back(x) #define szz(x) (int)x.size() #define rep(i,n) for(int i=0;i<n;i++) #define all(x) x.begin(),x.end() typedef tuple<int, int, int> t3; int main() { int T; scanf("%d", &T); rep(tt, T) { int N, p[1010]; scanf("%d", &N); for(int i=1;i<=N;i++) scanf("%d", p+i); int ans = -1; for(int i=1;i<=N;i++) { int chk[1010] = {}; chk[p[1]] = 1; int m = 1, ok = 1; for(int j=2;j<=N;j++) { if(m == i) ++m; if(chk[m] == 0 && p[j] != m) { ok = 0; break; } chk[p[j]] = 1; ++m; } if(!ok) continue; if(ans == -1) ans = i; else ans = 0; } if(ans == -1) ans = 0; printf("%d\n", ans); } return 0; }

Compilation message (stderr)

crazy.cpp: In function 'int main()':
crazy.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int T; scanf("%d", &T);
         ~~~~~^~~~~~~~~~
crazy.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
   ~~~~~^~~~~~~~~~
crazy.cpp:37:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for(int i=1;i<=N;i++) scanf("%d", p+i);
                         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...