Submission #515807

#TimeUsernameProblemLanguageResultExecution timeMemory
515807aris12345678Kamenčići (COCI21_kamencici)C++14
70 / 70
1 ms292 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d %d", &n, &k); string s; cin >> s; int l = 0, r = n-1, turn = 0, x = 1; vector<int> sum(2, 0); while(l <= r) { // cout << l << " " << r << " "; if(s[l] == 'P') l++; else if(s[r] == 'P') r--; else if(l+1 <= r && s[l+1] == 'C') l++, sum[turn]++; else if(l <= r-1 && s[r-1] == 'C') r--, sum[turn]++; else l++, sum[turn]++; // cout << turn << " " << sum[turn] << "\n"; if(sum[turn] == k) { if(turn == 0) printf("NE\n"); else printf("DA\n"); break; } turn ^= x; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...