Submission #90967

# Submission time Handle Problem Language Result Execution time Memory
90967 2018-12-25T10:34:35 Z kylych03 Crazy old lady (IZhO13_crazy) C++14
0 / 100
2 ms 372 KB
#include <bits/stdc++.h>
#define int long long
#define sc second
#define fr first
 
 int a[100001];
using namespace std;
main()
{
	int t,n,i,res;
	cin>>t;
	while(t--){
		cin>>n;
		bool f=true;
		for(i=1;i<=n;i++){
			cin>>a[i];
			if(a[i]!=i){
				f=false;
				res=i;
			}
		}
		if(n==1)
		cout<<1<<endl;
		else
		if(n==2 || f){
			cout<<0<<endl;
		}
		else
		cout<<a[res]<<endl;
	}
}

Compilation message

crazy.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
crazy.cpp: In function 'int main()':
crazy.cpp:29:14: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   cout<<a[res]<<endl;
              ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 372 KB Output isn't correct
3 Halted 0 ms 0 KB -