Submission #36906603
Source Code Expand
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(0); cin.tie(0); #define int long long using namespace std; const int N = 2e3+5; int dp[N][N], grid[N][N]; signed main(){ fastio int n,m; cin >> n >> m; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ char c; cin >> c; if(c == '+') grid[i][j] = 1; else grid[i][j] = -1; } } for(int i = n; i >= 1; i--){ for(int j = m; j >= 1; j--){ if(i == n && j == m) dp[i][j] = 0; else if(i == n) dp[i][j] = dp[i][j+1]; else if(j == m) dp[i][j] = dp[i+1][j]; else{ if((i+j)%2) dp[i][j] = min(dp[i][j+1],dp[i+1][j]); else dp[i][j] = max(dp[i][j+1],dp[i+1][j]); } if(i == 1 && j == 1) continue; dp[i][j] += ((i+j)%2 ? 1 : -1) * grid[i][j]; } } if(dp[1][1] > 0) cout << "Takahashi\n"; else if(dp[1][1] == 0) cout << "Draw\n"; else cout << "Aoki\n"; }
Submission Info
Submission Time | |
---|---|
Task | D - Game in Momotetsu World |
User | SamDaBest |
Language | C++ (GCC 9.2.1) |
Score | 400 |
Code Size | 916 Byte |
Status | AC |
Exec Time | 89 ms |
Memory | 66224 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | extreme_00.txt, handmade_00.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
extreme_00.txt | AC | 89 ms | 66180 KiB |
handmade_00.txt | AC | 2 ms | 3464 KiB |
random_00.txt | AC | 88 ms | 66176 KiB |
random_01.txt | AC | 87 ms | 66224 KiB |
random_02.txt | AC | 89 ms | 66176 KiB |
random_03.txt | AC | 88 ms | 66120 KiB |
random_04.txt | AC | 6 ms | 5336 KiB |
random_05.txt | AC | 2 ms | 3540 KiB |
random_06.txt | AC | 13 ms | 19616 KiB |
random_07.txt | AC | 8 ms | 6936 KiB |
random_08.txt | AC | 61 ms | 51136 KiB |
random_09.txt | AC | 21 ms | 18036 KiB |
sample_01.txt | AC | 2 ms | 3520 KiB |
sample_02.txt | AC | 2 ms | 3604 KiB |
sample_03.txt | AC | 2 ms | 3532 KiB |