제출 #200395

#제출 시각아이디문제언어결과실행 시간메모리
200395quocnguyen1012Sajam (COCI18_sajam)C++14
90 / 90
30 ms5244 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; const int maxn = 1005; int a[maxn][maxn], cnt[2][maxn], N; bool mark[2][maxn]; int sum = 0, K; signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("A.INP", "r")){ freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); } cin >> N >> K; for (int i = 1; i <= N; ++i){ for (int j = 1; j <= N; ++j){ char x; cin >> x; a[i][j] = (x == 'o'); cnt[0][i] += a[i][j]; cnt[1][j] += a[i][j]; sum += a[i][j]; } } if (sum <= K){ cout << "DA"; return 0; } for (int z = 1; z <= N; ++z){ int type, mx = -1, ind; for (int t = 0; t < 2; ++t){ for (int i = 1; i <= N; ++i){ if (mx < cnt[t][i] && mark[t][i] == false){ mx = cnt[t][i]; ind = i; type = t; } } } sum -= cnt[type][ind]; cnt[type][ind] = N - cnt[type][ind]; sum += cnt[type][ind]; mark[type][ind] = true; if (sum <= K){ cout << "DA"; return 0; } if (type == 0){ for (int i = 1; i <= N; ++i){ cnt[1][i] -= a[ind][i]; a[ind][i] ^= 1; cnt[1][i] += a[ind][i]; } } else{ for (int i = 1; i <= N; ++i){ cnt[0][i] -= a[i][ind]; a[i][ind] ^= 1; cnt[0][i] += a[i][ind]; } } } cout << "NE"; }

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

sajam.cpp: In function 'int main()':
sajam.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("A.INP", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
sajam.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("A.OUT", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sajam.cpp:39:24: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int type, mx = -1, ind;
                        ^~~
sajam.cpp:47:25: warning: 'type' may be used uninitialized in this function [-Wmaybe-uninitialized]
     sum -= cnt[type][ind];
            ~~~~~~~~~~~~~^
#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...