제출 #868140

#제출 시각아이디문제언어결과실행 시간메모리
868140heeheeheehaawRed-blue table (IZhO19_stones)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int a[1005][1005]; int b[1005][1005]; int ra, rb; int main() { int t, n, m; cin>>t; while(t--) { cin>>n>>m; ra = 0, rb = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) a[i][j] = 0, b[i][j] = 1; int ln = m / 2; if(m % 2 == 0) ln--; int lm = n / 2; if(n % 2 == 0) lm--; queue<pair<int, int>> q; for(int i = 1; i <= n; i++) if(ln > 0) q.push({ln, i}); for(int j = 1; j <= m; j++) { int nr = n - lm; while(nr-- && (int)q.size()) { pair<int, int> curr = q.front(); q.pop(); a[curr.second][j] = 1; if(curr.first > 1) q.push({curr.first - 1, curr.second}); } } while((int)q.size()) q.pop(); for(int j = 1; j <= m; j++) if(lm > 0) q.push({lm, j}); for(int i = 1; i <= n; i++) { int nr = m - ln; while(nr-- && (int)q.size()) { pair<int, int> curr = q.front(); q.pop(); b[i][curr.second] = 0; if(curr.first > 1) q.push({curr.first - 1, curr.second}); } } for(int i = 1; i <= n; i++) { int nr0 = 0, nr1 = 0; for(int j = 1; j <= m; j++) if(a[i][j] == 0) nr0++; else nr1++; if(nr0 > nr1) ra++; } for(int j = 1; j <= m; j++) { int nr0 = 0, nr1 = 0; for(int i = 1; i <= n; i++) if(a[i][j] == 0) nr0++; else nr1++; if(nr0 < nr1) ra++; } for(int i = 1; i <= n; i++) { int nr0 = 0, nr1 = 0; for(int j = 1; j <= m; j++) if(b[i][j] == 0) nr0++; else nr1++; if(nr0 > nr1) rb++; } for(int j = 1; j <= m; j++) { int nr0 = 0, nr1 = 0; for(int i = 1; i <= n; i++) if(b[i][j] == 0) nr0++; else nr1++; if(nr0 < nr1) rb++; } if(ra < rb) swap(a, b); cout<<max(ra, rb)<<'\n';a for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(a[i][j] == 0) cout<<"+"; else cout<<"-"; } cout<<'\n'; } } return 0; }

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

stones.cpp: In function 'int main()':
stones.cpp:102:34: error: expected ';' before 'for'
  102 |         cout<<max(ra, rb)<<'\n';a
      |                                  ^
      |                                  ;
  103 |         for(int i = 1; i <= n; i++)
      |         ~~~                       
stones.cpp:102:33: warning: statement has no effect [-Wunused-value]
  102 |         cout<<max(ra, rb)<<'\n';a
      |                                 ^
stones.cpp:103:24: error: 'i' was not declared in this scope
  103 |         for(int i = 1; i <= n; i++)
      |                        ^