Submission #901246

#TimeUsernameProblemLanguageResultExecution timeMemory
901246CodeussTreasure (info1cup19_treasure)C++17
100 / 100
17 ms1116 KiB
#include <bits/stdc++.h> using namespace std; #define NMAX 200001 char stiv[NMAX]; int main(void){ int n , k, top = 0; string s; cin >> n >> k; cin >> s; for(int i= 0;i<s.size();i++){ int cnt1 = 0, top_aux = top; //cout << top << ' '; while(top_aux && stiv[top_aux] == s[i]){ top_aux--; cnt1++; } // cout << top_aux << '\n'; if(cnt1 + 1 == k){ top = top_aux; }else stiv[++top] = s[i]; } for(int i = 1;i<=top;i++){ cout << stiv[i]; } }

Compilation message (stderr)

treasure.cpp: In function 'int main()':
treasure.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i= 0;i<s.size();i++){
      |                  ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...