Submission #40987

#TimeUsernameProblemLanguageResultExecution timeMemory
40987XmtosXIgra (COCI17_igra)C++14
100 / 100
3 ms696 KiB
#include <bits/stdc++.h> using namespace std; int n,a[200],b[200]; string s1,s2,s; bool check () { for (int i=0;i<=b['a'];i++) { int x= (a['b']-i); int y= (a['c']-(b['a']-i)); if (x<0||y<0) continue; if (x>b['c']||y>b['b']) continue; return 1; } return 0; } int main() { cin >>n>>s1>>s2; for (int i=0;i<n;i++) a[s1[i]]++,b[s2[i]]++; for (int i=0;i<n;i++) { b[s2[i]]--; for (int j='a';j<='c';j++) { if (j==s2[i]||!a[j]) continue; a[j]--; if (check()) { s+=j; break; } a[j]++; } } cout <<s; return 0; }

Compilation message (stderr)

igra.cpp: In function 'int main()':
igra.cpp:23:16: warning: array subscript has type 'char' [-Wchar-subscripts]
         a[s1[i]]++,b[s2[i]]++;
                ^
igra.cpp:23:27: warning: array subscript has type 'char' [-Wchar-subscripts]
         a[s1[i]]++,b[s2[i]]++;
                           ^
igra.cpp:26:16: warning: array subscript has type 'char' [-Wchar-subscripts]
         b[s2[i]]--;
                ^
#Verdict Execution timeMemoryGrader output
Fetching results...