# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
163807 |
2019-11-15T12:54:46 Z |
Ort |
Retro (COCI17_retro) |
C++11 |
|
500 ms |
57080 KB |
#include<bits/stdc++.h>
#define MAX 305
#define HMAX 155
#define inf 1000000
using namespace std;
int n, m, sy, sx;
int dx[3] = {-1, 0, 1};
int dy[3] = {1, 1, 1};
int dp[MAX][MAX][HMAX];
char mat[MAX][MAX];
bool inside(int y, int x) {return y>=0 && x>0 && y<=n && x<=m;}
void input();
int main() {
input();
memset(dp, -1, sizeof(dp));
for(int i=0;i<n;i++)
for(int j=1;j<=m;j++)
dp[i][j][0] = 0;
for(int i=0;i<n;i++)
for(int j=1;j<=m;j++)
for(int k=0;k<n;k++) {
if(dp[i][j][k]==-1) continue;
for(int l=0;l<3;l++) {
int y = i+dy[l];
int x = j+dx[l];
if(!inside(y,x)) continue;
if(mat[y][x]==')') dp[y][x][k+1] = max(dp[y][x][k+1], dp[i][j][k]+1);
if(mat[y][x]=='(' && k>0) dp[y][x][k-1] = max(dp[y][x][k-1], dp[i][j][k]+1);
if(mat[y][x]=='.' || mat[y][x]=='M') dp[y][x][k] = max(dp[y][x][k], dp[i][j][k]);
}
}
cout << dp[sy][sx][0] << "()";
return 0;
}
void input() {
cin >> n >> m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) {
cin >> mat[i][j];
if(mat[i][j]=='M') sy = i, sx = j;
}
for(int i=1;i<=m;i++) mat[0][i] = '*';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
56824 KB |
Expected integer, but "4()" found |
2 |
Incorrect |
49 ms |
56824 KB |
Expected integer, but "8()" found |
3 |
Incorrect |
50 ms |
56824 KB |
Expected integer, but "8()" found |
4 |
Incorrect |
49 ms |
56796 KB |
Expected integer, but "8()" found |
5 |
Incorrect |
50 ms |
56696 KB |
Expected integer, but "10()" found |
6 |
Incorrect |
67 ms |
56824 KB |
Expected integer, but "40()" found |
7 |
Incorrect |
54 ms |
56800 KB |
Expected integer, but "44()" found |
8 |
Incorrect |
51 ms |
56824 KB |
Expected integer, but "46()" found |
9 |
Incorrect |
56 ms |
56824 KB |
Expected integer, but "54()" found |
10 |
Incorrect |
56 ms |
56824 KB |
Expected integer, but "52()" found |
11 |
Incorrect |
446 ms |
56868 KB |
Expected integer, but "180()" found |
12 |
Incorrect |
407 ms |
56992 KB |
Expected integer, but "172()" found |
13 |
Incorrect |
232 ms |
56956 KB |
Expected integer, but "178()" found |
14 |
Incorrect |
225 ms |
57028 KB |
Expected integer, but "178()" found |
15 |
Execution timed out |
534 ms |
57080 KB |
Time limit exceeded |
16 |
Incorrect |
500 ms |
57004 KB |
Expected integer, but "204()" found |
17 |
Execution timed out |
507 ms |
56996 KB |
Time limit exceeded |
18 |
Incorrect |
403 ms |
56952 KB |
Expected integer, but "194()" found |
19 |
Execution timed out |
544 ms |
57052 KB |
Time limit exceeded |
20 |
Incorrect |
494 ms |
57080 KB |
Expected integer, but "202()" found |