結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-08-18 00:52:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,353 bytes |
| コンパイル時間 | 355 ms |
| コンパイル使用メモリ | 52,032 KB |
| 最終ジャッジ日時 | 2024-11-14 19:09:28 |
| 合計ジャッジ時間 | 1,007 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:10:6: error: variable or field ‘nya’ declared void
10 | void nya(vector<string> &kort, int dr, int dc) {
| ^~~
main.cpp:10:10: error: ‘vector’ was not declared in this scope
10 | void nya(vector<string> &kort, int dr, int dc) {
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:10:23: error: expected primary-expression before ‘>’ token
10 | void nya(vector<string> &kort, int dr, int dc) {
| ^
main.cpp:10:26: error: ‘kort’ was not declared in this scope
10 | void nya(vector<string> &kort, int dr, int dc) {
| ^~~~
main.cpp:10:32: error: expected primary-expression before ‘int’
10 | void nya(vector<string> &kort, int dr, int dc) {
| ^~~
main.cpp:10:40: error: expected primary-expression before ‘int’
10 | void nya(vector<string> &kort, int dr, int dc) {
| ^~~
main.cpp:25:12: error: ‘vector’ was not declared in this scope
25 | bool check(vector<string> kort) {
| ^~~~~~
main.cpp:25:12: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:25:25: error: expected primary-expression before ‘>’ token
25 | bool check(vector<string> kort) {
| ^
main.cpp:25:27: error: ‘kort’ was not declared in this scope
25 | bool check(vector<string> kort) {
| ^~~~
main.cpp: In function ‘int main()’:
main.cpp:39:3: error: ‘vector’ was not declared in this scope
39 | vector<string> kort(h);
| ^~~~~~
main.cpp:39:3: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:39:16: error:
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};
int h, w;
void nya(vector<string> &kort, int dr, int dc) {
for(int r : range(h)) {
for(int c : range(w)) {
if(kort[r][c] != '#') { continue; }
int nr = r + dr,
nc = c + dc;
if(nr < 0 || h <= nr || nc < 0 || w <= nc) { continue; }
if(r == nr && c == nc) { continue; }
if(kort[nr][nc] != '#') { continue; }
kort[r][c] = 'R';
kort[nr][nc] = 'B';
}
}
}
bool check(vector<string> kort) {
int red = 0, blue = 0;
for(int r : range(h)) {
for(int c : range(w)) {
if(kort[r][c] == '#') { return false; }
if(kort[r][c] == 'R') { red++; }
if(kort[r][c] == 'B') { blue++; }
}
}
return red == blue && red > 0;
}
int main(void) {
scanf("%d%d", &h, &w);
vector<string> kort(h);
for(int i : range(h)) { cin >> kort[i]; }
for(int dr : range(-h, h)) {
for(int dc : range(-w, w)) {
vector<string> copy = kort;
nya(copy, dr, dc);
if(check(copy)) {
puts("YES");
return 0;
}
}
}
puts("NO");
return 0;
}