제출 #1270813

#제출 시각아이디문제언어결과실행 시간메모리
1270813SmuggingSpunSajam (COCI18_sajam)C++20
90 / 90
19 ms1428 KiB
#include<bits/stdc++.h> #define taskname "C" using namespace std; template<class T>bool minimize(T& a, T b){ if(a > b){ a = b; return true; } return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } int n, k; cin >> n >> k; vector<vector<char>>a(n + 1, vector<char>(n + 1)); vector<int>cnt(n + 1, 0); for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ cin >> a[i][j]; if(a[i][j] == 'o'){ cnt[j]++; } } } int ans = 0; for(int i = 1; i <= n; i++){ ans += min(cnt[i], n - cnt[i]); } for(int i = 1; i <= n; i++){ vector<int>temp = cnt; for(int j = 1; j <= n; j++){ if(a[i][j] == 'o'){ temp[j]--; } else{ temp[j]++; } } int cur_ans = 0; for(int j = 1; j <= n; j++){ cur_ans += min(temp[j], n - temp[j]); } if(minimize(ans, cur_ans)){ swap(temp, cnt); } } cout << (ans <= k ? "DA" : "NE"); }

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

sajam.cpp: In function 'int main()':
sajam.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...