提出 #6015655
ソースコード 拡げる
#include <iostream>
#include <vector>
#include <map>
using namespace std;
vector<pair<int,int>> d(4);
d[0] = make_pair(1,0);
d[1] = make_pair(0,1);
d[2] = make_pair(-1,0);
d[3] = make_pair(0,-1);
int H, W;
int check(int w, int h, vector<vector<char>> &V, vector<vector<bool>> &C){
int tmp = 1;
//黒の連結成分に含まれる黒の数をadjにpush_back
for(int i = 0; i < 4; i++){
int wp = w + d[i].first;
int hp = h + d[i].second;
if(wp < 0 || wp > W - 1 || hp < 0 || hp > H - 1)continue;
if(V[wp][hp] == '#'){
tmp += check(wp, hp, V, C);
C[wp,hp] = true;
}
}
return tmp;
}
int main(){
cin >> H >> W;
vector<vector<char>> V(H,vector<char> (W,'x'));
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
cin >> V[i][j];
}
}
vector<int> adj;
vector<vector<bool>> C(H,vector<bool> (W,false));
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if(C[i][j])continue;
if(C[i][j] == '#'){
adj.push_back(check(i ,j ,V, C));
}
C[i][j] = true;
}
}
sort(adj.begin(), adj.end());
if(adj[0] <= 1) cout << "Yes";
else cout << "No";
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - Day of Takahashi |
| ユーザ | otsuyutori |
| 言語 | C++14 (GCC 5.4.1) |
| 得点 | 0 |
| コード長 | 1223 Byte |
| 結果 | CE |
コンパイルエラー
./Main.cpp:8:1: error: ‘d’ does not name a type
d[0] = make_pair(1,0);
^
./Main.cpp:9:1: error: ‘d’ does not name a type
d[1] = make_pair(0,1);
^
./Main.cpp:10:1: error: ‘d’ does not name a type
d[2] = make_pair(-1,0);
^
./Main.cpp:11:1: error: ‘d’ does not name a type
d[3] = make_pair(0,-1);
^
./Main.cpp: In function ‘int check(int, int, std::vector<std::vector<char> >&, std::vector<std::vector<bool> >&)’:
./Main.cpp:24:18: error: no match for ‘operator=’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> > >::value_type {aka std::vector<bool>}’ and ‘bool’)
C[wp,hp] = true;
^
In file included from /usr/include/c++/5/vector:65:0,
from ./Main.cpp:2:
/usr/include/c++/5/bits/stl_bvector.h:680:5: note: candidate: std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(const std::vector<bool, _Alloc>&) [with _Alloc = std::allocator<bool>]
operator=(const vector& __x)
^
/usr/include/c++/5/bits/stl_bvector.h:680:5:...