제출 #791207

#제출 시각아이디문제언어결과실행 시간메모리
791207n3rm1nDango Maker (JOI18_dango_maker)C++17
0 / 100
98 ms211744 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 3005, MAXX = 9e6 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, m; char a[MAXN][MAXN]; int cnt; vector < int > v[MAXX]; void read() { cin >> n >> m; for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= m; ++ j) { cin >> a[i][j]; } } } int dir0[MAXN][MAXN], dir1[MAXN][MAXN]; int type[MAXX]; void precompute() { for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= m-2; ++ j) { if(a[i][j] == 'R' && a[i][j+1] == 'G' && a[i][j+2] == 'W') { cnt ++; //g.push_back(tri(i, j, 0, cnt)); type[cnt] = 1; dir0[i][j] = cnt; dir0[i][j+1] = cnt; dir0[i][j+2] = cnt; } } } for (int i = 1; i <= n-2; ++ i) { for (int j = 1; j <= m; ++ j) { if(a[i][j] == 'R' && a[i+1][j] == 'G' && a[i+2][j] == 'W') { cnt ++; type[cnt] = 2; //g.push_back(tri(i, j, 1, cnt)); dir1[i][j] = cnt; dir1[i][j+1] = cnt; dir1[i][j+2] = cnt; } } } for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= m; ++ j) { if(dir0[i][j] && dir1[i][j]) { v[dir0[i][j]].push_back(dir1[i][j]); v[dir1[i][j]].push_back(dir0[i][j]); } } } } int used[MAXN]; int cnt1 = 0, cnt2 = 0; void dfs(int beg) { used[beg] = 1; if(type[beg] == 1)cnt1 ++; else cnt2 ++; int nb; for (int i = 0; i < v[beg].size(); ++ i) { nb = v[beg][i]; if(!used[nb])dfs(nb); } } void solve() { int ans = 0; for (int i = 1; i <= cnt; ++ i) { if(!used[i]) { cnt1 = 0; cnt2 = 0; dfs(i); ans += max(cnt1, cnt2); } } cout << ans << endl; } int main() { speed(); read(); precompute(); solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

dango_maker.cpp: In function 'void dfs(int)':
dango_maker.cpp:80:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for (int i = 0; i < v[beg].size(); ++ i)
      |                     ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...