#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi pair<int,int>
#define sz(x) (int)x.size()
const int N = 1e5;
int n,flag;
char grid[10][N+10];
bool vis[10][N+10];
vector<int> ans;
void dfs(int i,int j){
if(flag || vis[i][j] || grid[i][j] == 'X') return ;
vis[i][j] = 1;
flag = (j == n-1);
if(i == 9){
dfs(i,j+1);
ans.push_back(j);
dfs(i-1,j+1);
ans.pop_back();
}
else if(i == 0){
dfs(i,j+1);
ans.push_back(j);
dfs(i+1,j+1);
ans.pop_back();
}
else{
//cout << i << ' ' << j << '\n';
if(sz(ans)%2 == 0) ans.push_back(j);
dfs(i-1,j+1);
if(sz(ans)%2 == 0) ans.pop_back();
if(sz(ans)%2 == 1) ans.push_back(j);
dfs(i+1,j+1);
if(sz(ans)%2 == 1) ans.pop_back();
}
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i=0;i<10;i++){
for(int j=0;j<n;j++){
cin >> grid[i][j];
}
}
dfs(9,0);
if(sz(ans)%2){
if(ans.back() == n-1) ans.pop_back();
else ans.push_back(n-1);
}
cout << sz(ans)/2 << '\n';
for(int i=0;i<sz(ans)-1;i+=2){
cout << ans[i] << ' ' << ans[i+1]-ans[i] << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Integer -2 violates the range [1, 38] |
3 |
Incorrect |
0 ms |
468 KB |
Integer 0 violates the range [1, 95] |
4 |
Incorrect |
1 ms |
348 KB |
Integer 0 violates the range [1, 853] |
5 |
Incorrect |
1 ms |
604 KB |
Integer -2 violates the range [1, 4339] |
6 |
Incorrect |
2 ms |
736 KB |
Integer -1 violates the range [1, 6271] |
7 |
Incorrect |
4 ms |
1884 KB |
Integer -2 violates the range [1, 19293] |
8 |
Incorrect |
11 ms |
3692 KB |
Integer 0 violates the range [1, 47490] |
9 |
Incorrect |
13 ms |
5340 KB |
Integer 0 violates the range [1, 72179] |
10 |
Incorrect |
18 ms |
7132 KB |
Integer -6 violates the range [1, 100000] |