# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1270813 | SmuggingSpun | Sajam (COCI18_sajam) | C++20 | 19 ms | 1428 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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |