// Copyright © 2018 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 100005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;
int N, M, idx;
char a[14][MAX];
int vis[14][MAX];
int dfs( int x , int y )
{
if( y == M )
return vis[x][y] = y;
// Subir
int mx = x - 1;
int my = y + 1;
if( ! mx ) mx = 1;
if( vis[x][y] )
return vis[x][y];
int ans = y;
if( a[mx][my] == '.' )
ans = max( ans , dfs( mx , my ) );
mx = x + 1;
if( mx == 11 ) mx = 10;
if( a[mx][my] == '.' )
ans = max( ans , dfs( mx , my ) );
return vis[x][y] = ans;
}
int main()
{
optimiza_io
cin >> M;
N = 10;
for( int i = 1; i <= N; i ++ )
for( int j = 1; j <= M; j ++ )
cin >> a[i][j];
dfs( 10 , 1 );
int j = 10, moves = 0, subiendo = false;
for( int i = 1; i < N; i ++ )
{
int sigj = j - 1;
if( vis[sigj][i] == M )
{
j = sigj;
if( ! subiendo )
{
subiendo = true;
moves++;
}
}
else
{
j ++;
if( j == 11 ) j --;
subiendo = false;
}
}
cout << moves << "\n";
j = 10, subiendo = false, idx = 0;
for( int i = 1; i < M; i ++ )
{
int sigj = j - 1;
if( vis[sigj][i] == M )
{
j = sigj;
if( ! subiendo )
{
subiendo = true;
idx = i;
cout << i - 1 << " ";
}
}
else
{
if( subiendo ) cout << i - idx << "\n";
idx = 0;
j ++;
if( j == 11 ) j --;
subiendo = false;
}
}
if( idx )
cout << N - idx << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Crashed with an obstacle |
2 |
Incorrect |
2 ms |
488 KB |
Extra information in the output file |
3 |
Incorrect |
2 ms |
728 KB |
Crashed with an obstacle |
4 |
Incorrect |
2 ms |
728 KB |
Crashed with an obstacle |
5 |
Incorrect |
4 ms |
1176 KB |
Crashed with an obstacle |
6 |
Incorrect |
4 ms |
1584 KB |
Crashed with an obstacle |
7 |
Incorrect |
10 ms |
3312 KB |
Crashed with an obstacle |
8 |
Incorrect |
23 ms |
6956 KB |
Crashed with an obstacle |
9 |
Incorrect |
33 ms |
10512 KB |
Crashed with an obstacle |
10 |
Incorrect |
38 ms |
14548 KB |
Crashed with an obstacle |