#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define fix fixed<<setprecision(20)
#define endl'\n'
#define c(x) cout<<x<<endl
#define int ll
//int a[200090],pre[200090],suf[200090];
int mx[]={0,0,-1,1},my[]={-1,1,0,0};
int a[600][600];
bool vis[200][200];
int n,m;
bool inside(int i,int j){
return (i&&i<=n&&j&&j<=m);
}
void dfs (int i,int j){
vis[i][j]=1;
for(int k=0;k<4;k++){
int nx=i+mx[k],ny=j+my[k];
if(inside(nx,ny)&& !vis[nx][ny]&& a[nx][ny]=='*') { vis[nx][ny]=1;
dfs(nx,ny);}
}
}
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin>>n;
int k; cin>>k;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
cin>>a[i][j];
int x=2,y=1;
int ans=0;
for(int i=1;i<k-1;i++){
ans= a[x][y];
//cout<<ans<<endl;
y=x;
x=ans;
}
cout<<ans<<endl;
}
Compilation message
politicari.cpp:7:9: warning: ISO C++11 requires whitespace after the macro name
7 | #define endl'\n'
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Execution timed out |
1093 ms |
2780 KB |
Time limit exceeded |
3 |
Execution timed out |
1026 ms |
3164 KB |
Time limit exceeded |
4 |
Execution timed out |
1071 ms |
3164 KB |
Time limit exceeded |
5 |
Execution timed out |
1057 ms |
3560 KB |
Time limit exceeded |
6 |
Execution timed out |
1068 ms |
3532 KB |
Time limit exceeded |
7 |
Incorrect |
0 ms |
356 KB |
Output isn't correct |
8 |
Correct |
2 ms |
2720 KB |
Output is correct |
9 |
Correct |
5 ms |
2652 KB |
Output is correct |
10 |
Correct |
10 ms |
3164 KB |
Output is correct |
11 |
Correct |
15 ms |
3576 KB |
Output is correct |
12 |
Correct |
13 ms |
3540 KB |
Output is correct |
13 |
Execution timed out |
1074 ms |
2396 KB |
Time limit exceeded |
14 |
Execution timed out |
1060 ms |
2652 KB |
Time limit exceeded |