Submission #67612

#TimeUsernameProblemLanguageResultExecution timeMemory
67612win11905Igra (COCI17_igra)C++11
100 / 100
6 ms616 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e3+5; int n, a[3], b[3]; char A[N], B[N]; bool check() { for(int i = 0; i <= a[0]; ++i) { int x = b[1] - i; int y = b[2] - (a[0] - i); if(x < 0 || y < 0) continue; if(x <= a[2] && y <= a[1]) return true; } return false; } int main() { scanf("%d", &n); scanf("%s %s", B+1, A+1); for(int i = 1; i <= n; ++i) { A[i] -= 'a', B[i] -= 'a'; a[A[i]]++, b[B[i]]++; } for(int i = 1; i <= n; ++i) { a[A[i]]--; for(int j = 0; j < 3; ++j) { b[j]--; if(A[i] != j && check()) { printf("%c", j+'a'); break; } b[j]++; } } }

Compilation message (stderr)

igra.cpp: In function 'int main()':
igra.cpp:24:15: warning: array subscript has type 'char' [-Wchar-subscripts]
         a[A[i]]++, b[B[i]]++;
               ^
igra.cpp:24:26: warning: array subscript has type 'char' [-Wchar-subscripts]
         a[A[i]]++, b[B[i]]++;
                          ^
igra.cpp:27:15: warning: array subscript has type 'char' [-Wchar-subscripts]
         a[A[i]]--;
               ^
igra.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
igra.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s %s", B+1, A+1);
     ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...