Submission #341316

#TimeUsernameProblemLanguageResultExecution timeMemory
341316A_DPolitičari (COCI20_politicari)C++14
70 / 70
58 ms4332 KiB
/* ID: antwand1 TASK: pprime LANG: C++ */ #include <bits/stdc++.h> #define ll long long #define int long long #define du long double #define F first #define S second #define FOR(a,b) for(int a=1;a<=b;a++) #define FORl(a,b) for(a=1;a<=b;a++) #define FOR0(a,b) for(int a=1;a<b;a++) #define FORl0(a,b) for(a=0;a<b;a++) using namespace std; const int N=501; int a[N][N]; int vis[N][N]; vector<int> vec; vector<int> v; main() { //freopen("pprime.in","r",stdin);freopen("pprime.out","w",stdout); int n,k; cin>>n>>k; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cin>>a[i][j]; } } vec.push_back(1); vec.push_back(2); int x=2,y=1; int cnt=2,cur=0; while(1){ // cout<<x<<" "<<y<<endl; if(vis[x][y]){ cur=vis[x][y]; break; } vis[x][y]=cnt++; vec.push_back(a[x][y]); int Y=x; int X=a[x][y]; x=X; y=Y; } // cout<<"\n\n"; //cout<<cur<<"\n\n"; for(int i=0;i<cur;i++){ k--; if(!k){ cout<<vec[i]; return 0; } } for(int i=cur;i<vec.size();i++){ v.push_back(vec[i]); } int sz=v.size(); // cout<<"\n\n\n"; //for(int i=0;i<vec.size();i++)cout<<vec[i]<<" "; // cout<<"\n\n\n"; // for(int i=0;i<v.size();i++)cout<<v[i]<<" "; //cout<<"\n\n\n\n"; k--; k%=sz; cout<<v[k]<<endl; }

Compilation message (stderr)

politicari.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main()
      |      ^
politicari.cpp: In function 'int main()':
politicari.cpp:58:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=cur;i<vec.size();i++){
      |                   ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...