# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
311205 | phathnv | Sajam (COCI18_sajam) | C++11 | 138 ms | 1528 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define taskname "SAJAM"
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
const int N = 1001;
int n, k;
char s[N];
bitset <N> a[N];
void readInput(){
scanf("%d %d", &n, &k);
for(int i = 1; i <= n; i++){
scanf("%s", s + 1);
for(int j = 1; j <= n; j++)
a[i][j] = (s[j] == 'o');
}
}
int calc(int x1, int x2){
int res = (a[x1] ^ a[x2]).count();
if (res > n / 2)
res = n - res;
return res;
}
void solve(){
for(int i = 1; i <= n; i++){
int cnt = 0;
for(int j = 1; j <= n; j++)
cnt += calc(i, j);
if (cnt <= k){
printf("DA");
return;
}
}
if (k < n){
printf("NE");
return;
}
for(int i = 1; i <= n; i++){
a[1][i].flip();
int cnt = 1;
for(int j = 1; j <= n; j++)
cnt += calc(1, j);
if (cnt <= k){
printf("DA");
return;
}
a[1][i].flip();
}
printf("NE");
}
int main(){
//freopen(taskname".inp", "r", stdin);
//freopen(taskname".out", "w", stdout);
readInput();
solve();
return 0;
}
컴파일 시 표준 에러 (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... |