# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
180290 | Linca_Robert | Sajam (COCI18_sajam) | C++14 | 77 ms | 9248 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int DIM = 1e4 + 5;
int cnt[2][DIM], N, K, a[DIM][DIM], nr;
bool mrk[2][DIM];
char s[DIM];
int main(){
cin >> N >> K;
for( int i = 1; i <= N; i++ ){
cin >> s + 1;
for( int j = 1; j <= N; j++ ){
char x = s[j];
a[i][j] = (x == 'o');
cnt[0][i] += a[i][j];
cnt[1][j] += a[i][j];
nr += a[i][j];
}
}
if( nr <= K ){
printf( "DA\n" );
return 0;
}
for( int pas = 1; pas <= 2 * N; pas++ ){
int maxi = 0, tp, ind;
for( int t = 0; t <= 1; t++ )
for( int i = 1; i <= N; i++ )
if( maxi < cnt[t][i] && mrk[t][i] == false )
maxi = cnt[t][i], tp = t, ind = i;
nr += N - 2 * cnt[tp][ind];
cnt[tp][ind] = N - cnt[tp][ind];
mrk[tp][ind] = true;
if( tp == 0 ){
for( int j = 1; j <= N; j++ ){
cnt[1][j] -= a[ind][j];
a[ind][j] ^= 1;
cnt[1][j] += a[ind][j];
}
}else{
for( int i = 1; i <= N; i++ ){
cnt[0][i] -= a[i][ind];
a[i][ind] ^= 1;
cnt[0][i] += a[i][ind];
}
}
if( nr <= K ){
printf( "DA\n" );
return 0;
}
}
printf( "NE\n" );
return 0;
}
Compilation message (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... |