Submission #1982509
Source Code Expand
#include<iostream> #include<string> #include<cstdio> #include<algorithm> #include<cstdlib> #include<cmath> #include<vector> #include<deque> #include<queue> #include<stack> #include<utility> #include<array> #include<cassert> #include<list> #include<experimental/any> #include<cstring> #include<cctype> #include<ctime> #include<cstdbool> #include<cstdint> #include<cstddef> #include<set> #include<unordered_set> #include<bitset> using namespace std; using experimental::any; #define SPEEDY cin.tie(0);ios::sync_with_stdio(false); #define REP(i,n) for(int i=0;i<(n);i++) #define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i] #define FOR(i,X,n) for(int i=(X);i<(n);i++) #define EREP(i,n) for(int i=1;i<=n;i++) #define BitFOR(N) REP(Bit,1<<(N)) //#define MODE 1 #ifdef MODE #define DEB(X) cout<< #X <<": "<<X<<" "; #define DEB2(X) cout<<X<<" "; #define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" "; #define TFDEB(f) (f)? cout<<"true ":cout<<"false "; #define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X) #define END cout<<endl; #else #define DEB(X) {} #define DEB2(X) {} #define ARDEB(i,X) {} #define TFDEB(f) {} #define FORDEB(n,X) {} #define END {} #endif typedef long long int ll; typedef unsigned long long ull; typedef pair<int,int> P; #define ALL(X) X.begin(),X.end() struct edge{int to,cost;}; //struct edge{int from,cost,to;}; struct P2{int x,y;}; #define BIT(Bit,n) bitset<n>(Bit) #define Endl endl #define YN(f) cout<<((f)?"Yes":"No")<<endl const int MOD7=1000000007; const int INF=100000000; const int SET=1000; int main(){ int n,a[100010],dim=0; cin>>n; REP(i,n){ cin>>a[i]; } for(int i=0;i<1000000;i++){ if(i<20){DEB(dim)END} if(a[dim]==2){ cout<<i+1<<endl; return 0; } dim=a[dim]-1; } cout<<-1<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Trained? |
User | mamime19 |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1845 Byte |
Status | AC |
Exec Time | 44 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 39 ms | 640 KB |
02.txt | AC | 39 ms | 640 KB |
03.txt | AC | 38 ms | 640 KB |
04.txt | AC | 36 ms | 640 KB |
05.txt | AC | 44 ms | 640 KB |
06.txt | AC | 37 ms | 640 KB |
07.txt | AC | 36 ms | 640 KB |
08.txt | AC | 36 ms | 640 KB |
09.txt | AC | 37 ms | 640 KB |
10.txt | AC | 37 ms | 640 KB |
11.txt | AC | 36 ms | 640 KB |
12.txt | AC | 35 ms | 640 KB |
13.txt | AC | 36 ms | 640 KB |
14.txt | AC | 37 ms | 640 KB |
15.txt | AC | 39 ms | 640 KB |
16.txt | AC | 36 ms | 640 KB |
17.txt | AC | 35 ms | 640 KB |
18.txt | AC | 39 ms | 640 KB |
19.txt | AC | 4 ms | 256 KB |
20.txt | AC | 3 ms | 256 KB |
21.txt | AC | 1 ms | 256 KB |
22.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 4 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |