제출 #168822

#제출 시각아이디문제언어결과실행 시간메모리
168822abilRed-blue table (IZhO19_stones)C++14
0 / 100
2051 ms1144 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e4 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int ar[N][N], mx[N][N], curans; int n, m; void solve(int x, int y){ if(x - 1 == n && y == m || y - 1 == m && x == n){ int ans = 0; for(int i = 1;i <= n; i++){ int minus = 0, plus = 0; for(int j = 1;j <= m; j++){ if(ar[i][j] == 2){ minus++; } else{ plus++; } } if(plus > minus){ ans++; } } for(int i = 1;i <= m; i++){ int minus = 0, plus = 0; for(int j = 1;j <= n; j++){ if(ar[j][i] == 2){ minus++; } else{ plus++; } } if(plus < minus){ ans++; } } //cout << ans << endl; //for(int i = 1;i <= n; i++){ //for(int j = 1;j <= m; j++){ //if(ar[i][j] == 2){ //cout << "-"; //} //else{ //cout << "+"; //} //} //cout << endl; //} //cout << endl; if(curans < ans){ curans = ans; for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ mx[i][j] = ar[i][j]; } } } } if(x <= n && y <= m){ ar[x][y] = 1; solve(x + 1, y); solve(x, y + 1); ar[x][y] = 2; solve(x + 1, y); solve(x, y + 1); ar[x][y] = 0; } } main() { int t; cin >> t; while(t--){ cin >> n >> m; curans = 0; solve(1, 1); cout << curans << endl; for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ if(mx[i][j] == 2){ cout << "-"; } else{ cout << "+"; } } cout << endl; } } }

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

stones.cpp: In function 'void solve(int, int)':
stones.cpp:20:16: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  if(x - 1 == n && y == m || y - 1 == m && x == n){
     ~~~~~~~~~~~^~~~~~~~~
stones.cpp: At global scope:
stones.cpp:82:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...