Submission #22651166
Source Code Expand
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<vector<char> > A(H, vector<char>(W));
for(int i=0;i<H;i++) {
for(int j=0;j<W;j++) {
cin >> A[i][j];
}
}
vector<vector<long long> > dp(H, vector<long long>(W, 0));
for(int i=H-1;i>=0;i--) {
for(int j=W-1;j>=0;j--) {
if(i == H-1 && j == W-1) continue;
if((i+j) % 2 == 1) {
// Aokiがうつ
int tmp1 = 10000000, tmp2 = 10000000;
if(j != W - 1) {
if(A[i][j+1] == '-') tmp1 = dp[i][j+1] + 1;
if(A[i][j+1] == '+') tmp1 = dp[i][j+1] - 1;
}
if(i != H - 1) {
if(A[i+1][j] == '-') tmp2 = dp[i+1][j] + 1;
if(A[i+1][j] == '+') tmp2 = dp[i+1][j] - 1;
}
dp[i][j] = min(tmp1, tmp2);
}
if((i+j) % 2 == 0) {
int tmp1 = -10000000, tmp2 = -10000000;
// Takahashiがうつ
if(j != W - 1) {
if(A[i][j+1] == '-') tmp1 = dp[i][j+1] - 1;
if(A[i][j+1] == '+') tmp1 = dp[i][j+1] + 1;
}
if(i != H - 1) {
if(A[i+1][j] == '-') tmp2 = dp[i+1][j] - 1;
if(A[i+1][j] == '+') tmp2 = dp[i+1][j] + 1;
}
dp[i][j] = max(tmp1, tmp2);
}
}
}
if(dp[0][0] == 0) cout << "Draw" << endl;
if(dp[0][0] > 0) cout << "Takahashi" << endl;
if(dp[0][0] < 0) cout << "Aoki" << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Game in Momotetsu World |
| User | Tommy3 |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 1510 Byte |
| Status | AC |
| Exec Time | 207 ms |
| Memory | 38632 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 | 168 ms | 38632 KiB |
| handmade_00.txt | AC | 2 ms | 3452 KiB |
| random_00.txt | AC | 204 ms | 38536 KiB |
| random_01.txt | AC | 187 ms | 38492 KiB |
| random_02.txt | AC | 207 ms | 38460 KiB |
| random_03.txt | AC | 170 ms | 38564 KiB |
| random_04.txt | AC | 12 ms | 3852 KiB |
| random_05.txt | AC | 3 ms | 3508 KiB |
| random_06.txt | AC | 4 ms | 3760 KiB |
| random_07.txt | AC | 16 ms | 4140 KiB |
| random_08.txt | AC | 115 ms | 22792 KiB |
| random_09.txt | AC | 28 ms | 7500 KiB |
| sample_01.txt | AC | 2 ms | 3412 KiB |
| sample_02.txt | AC | 4 ms | 3604 KiB |
| sample_03.txt | AC | 2 ms | 3588 KiB |