Submission #645299

#TimeUsernameProblemLanguageResultExecution timeMemory
645299notmeTreasure (info1cup19_treasure)C++14
100 / 100
5 ms864 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 2e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, k; char s[MAXN]; int cnt[MAXN]; void solve() { cin >> n >> k; vector < pair < char, int > > v; for (int i = 1; i <= n; ++ i) { cin >> s[i]; if(v.size()) { if(v.back().first == s[i]) { v.back().second ++; v.back().second %= k; if(v.back().second == 0)v.pop_back(); } else v.push_back(make_pair(s[i], 1)); } else v.push_back(make_pair(s[i], 1)); } for (int i = 0; i < v.size(); ++ i) { for (int j = 0; j < v[i].second; ++ j) cout << v[i].first; } cout << endl; } int main() { speed(); solve(); return 0; }

Compilation message (stderr)

treasure.cpp: In function 'void solve()':
treasure.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<char, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i = 0; i < v.size(); ++ i)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...