Submission #180290

#TimeUsernameProblemLanguageResultExecution timeMemory
180290Linca_RobertSajam (COCI18_sajam)C++14
90 / 90
77 ms9248 KiB
#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)

sajam.cpp: In function 'int main()':
sajam.cpp:14:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         cin >> s + 1;
                ~~^~~
sajam.cpp:30:27: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
         int maxi = 0, tp, ind;
                           ^~~
sajam.cpp:35:34: warning: 'tp' may be used uninitialized in this function [-Wmaybe-uninitialized]
         nr += N - 2 * cnt[tp][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...