ログインしてください。
提出 #33486377
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int H, W, N;
cin >> H >> W >> N;
vector<vector<int>> a(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
cin >> a[i][j];
a[i][j]--;
}
}
vector<int> c(N);
for (int i = 0; i < N; i++) {
cin >> c[i];
}
bool ok = true;
vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, 1, 0, -1};
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
for (int k = 0; k < 4; k++) {
int ni = i + dy[k], nj = j + dx[k];
if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
if (a[ni][nj] != a[i][j] && c[a[ni][nj]] == c[a[i][j]]) {
ok = false;
}
}
}
}
cout << (ok ? "Yes" : "No") << endl;
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | F - 地図の塗り分け |
| ユーザ | tunamagur0 |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 7 |
| コード長 | 832 Byte |
| 結果 | AC |
| 実行時間 | 13 ms |
| メモリ | 3772 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 7 / 7 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, example0.txt, example1.txt, example2.txt, hand01.txt, hand02.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 9 ms | 3500 KiB |
| 001.txt | AC | 12 ms | 3768 KiB |
| 002.txt | AC | 2 ms | 3644 KiB |
| 003.txt | AC | 2 ms | 3488 KiB |
| 004.txt | AC | 3 ms | 3580 KiB |
| 005.txt | AC | 3 ms | 3616 KiB |
| 006.txt | AC | 11 ms | 3576 KiB |
| 007.txt | AC | 8 ms | 3508 KiB |
| 008.txt | AC | 3 ms | 3644 KiB |
| 009.txt | AC | 5 ms | 3640 KiB |
| 010.txt | AC | 2 ms | 3416 KiB |
| 011.txt | AC | 3 ms | 3660 KiB |
| 012.txt | AC | 10 ms | 3772 KiB |
| 013.txt | AC | 10 ms | 3704 KiB |
| 014.txt | AC | 8 ms | 3736 KiB |
| 015.txt | AC | 9 ms | 3704 KiB |
| 016.txt | AC | 2 ms | 3648 KiB |
| 017.txt | AC | 4 ms | 3628 KiB |
| 018.txt | AC | 9 ms | 3516 KiB |
| 019.txt | AC | 2 ms | 3504 KiB |
| example0.txt | AC | 2 ms | 3500 KiB |
| example1.txt | AC | 3 ms | 3572 KiB |
| example2.txt | AC | 2 ms | 3636 KiB |
| hand01.txt | AC | 13 ms | 3668 KiB |
| hand02.txt | AC | 13 ms | 3728 KiB |