Submission #92654

#TimeUsernameProblemLanguageResultExecution timeMemory
92654SamAndCrazy old lady (IZhO13_crazy)C++17
100 / 100
10 ms632 KiB
#include <iostream> #include <algorithm> using namespace std; const int N=1003; void sp(); void fp(); int n; int a[N]; bool c[N]; int main() { //fp(); int tt; cin>>tt; for(int ii=0;ii<tt;++ii) { cin>>n; for(int i=1;i<=n;++i) { cin>>a[i]; c[i]=false; } int ans=0; for(int i=1;i<=n;++i) { for(int i=1;i<=n;++i) c[i]=false; c[a[1]]=true; bool z=true; for(int j=1,k=2;j<=n,k<=n;++j,++k) { if(j==i) { --k; continue; } if(a[k]!=j && !c[j]) { z=false; break; } c[a[k]]=true; } if(z && !ans) ans=i; else if(z && ans) { ans=0; break; } } cout<<ans<<endl; } sp(); return 0; } void fp() { #ifndef OLYMP freopen("crazy.in","r",stdin); freopen("crazy.out","w",stdout); #endif } void sp() { #ifdef OLYMP system("pause"); #endif }

Compilation message (stderr)

crazy.cpp: In function 'int main()':
crazy.cpp:31:21: warning: left operand of comma operator has no effect [-Wunused-value]
    for(int j=1,k=2;j<=n,k<=n;++j,++k)
                    ~^~~
crazy.cpp: In function 'void fp()':
crazy.cpp:62:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("crazy.in","r",stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
crazy.cpp:63:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("crazy.out","w",stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...