Submission #105131

#TimeUsernameProblemLanguageResultExecution timeMemory
105131arthur_nascimentoSajam (COCI18_sajam)C++14
90 / 90
322 ms6484 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define maxn 1010 #define bs bitset<maxn> #define debug int ans = 0; bs col[maxn]; char M[maxn][maxn]; int dif[maxn][maxn]; void go(int n,int k){ for(int i=0;i<n;i++) for(int j=0;j<n;j++) col[j].set(i,M[i][j] == 'x'); for(int i=0;i<n;i++) for(int j=0;j<n;j++) dif[i][j] = (col[i] ^ col[j]).count(); for(int j=0;j<n;j++){ int s = 0; for(int jj=0;jj<n;jj++) s += min(dif[j][jj],n-dif[j][jj]); if(s <= k) ans = 1; } debug("%d\n",ans); } int main(){ int n,k; scanf("%d%d",&n,&k); for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf(" %c",&M[i][j]); go(n,k); for(int i=0;i<n;i++) for(int j=i;j<n;j++) swap(M[i][j], M[j][i]); go(n,k); for(int i=0;i<n;i++){ int s = 1; for(int j=1;j<n;j++){ int d = dif[0][j]; if(M[i][0] == M[i][j]) d++; else d--; s += min(d,n-d); } if(s <= k){ ans = 1; debug("i %d s %d\n",i,s); } } if(ans) printf("DA\n"); else printf("NE\n"); }

Compilation message (stderr)

sajam.cpp: In function 'void go(int, int)':
sajam.cpp:36:15: warning: left operand of comma operator has no effect [-Wunused-value]
  debug("%d\n",ans);
               ^~~
sajam.cpp: In function 'int main()':
sajam.cpp:70:24: warning: left operand of comma operator has no effect [-Wunused-value]
    debug("i %d s %d\n",i,s);
                        ^
sajam.cpp:70:26: warning: right operand of comma operator has no effect [-Wunused-value]
    debug("i %d s %d\n",i,s);
                          ^
sajam.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~
sajam.cpp:46:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&M[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
#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...