#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll n;
vector<vector<char>>a;
vector<ll>v;
ll dfs(ll x,ll y)
{
if(a[x][y]=='X')
return 0;
if(y==n-1)
return 1;
a[x][y]='X';
if(dfs(min((ll)9,x+1),y+1)==1)
return 1;
if(dfs(max((ll)0,x-1),y+1)==1)
{
v.push_back(y);
return 1;
}
return 0;
}
int main()
{
cin>>n;
a.assign(10,vector<char>(n));
for(ll i=0;i<10;i++)
{
for(ll j=0;j<n;j++)
cin>>a[i][j];
}
dfs(9,0);
reverse(v.begin(),v.end());
cout<<v.size()<<"\n";
for(auto i:v)
cout<<i<<" "<<1<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
3 ms |
600 KB |
Output is correct |
7 |
Correct |
8 ms |
1368 KB |
Output is correct |
8 |
Correct |
18 ms |
3160 KB |
Output is correct |
9 |
Correct |
29 ms |
4508 KB |
Output is correct |
10 |
Correct |
50 ms |
6356 KB |
Output is correct |