Submission #573219

#TimeUsernameProblemLanguageResultExecution timeMemory
573219SSRSCollider (IZhO11_collider)C++14
100 / 100
52 ms3192 KiB
#include <bits/stdc++.h> using namespace std; const int B = 1000; int main(){ int n, m; cin >> n >> m; string s; cin >> s; int cnt = (n + B - 1) / B; vector<string> t(cnt); for (int i = 0; i < n; i++){ t[i / B] += s[i]; } for (int i = 0; i < m; i++){ char c; cin >> c; if (c == 'a'){ int x, y; cin >> x >> y; x--; y--; char p; for (int j = 0; j < cnt; j++){ if (x < t[j].size()){ p = t[j][x]; t[j].erase(t[j].begin() + x); break; } x -= t[j].size(); } for (int j = 0; j < cnt; j++){ if (y <= t[j].size()){ t[j].insert(t[j].begin() + y, p); break; } y -= t[j].size(); } } if (c == 'q'){ int x; cin >> x; x--; for (int j = 0; j < cnt; j++){ if (x < t[j].size()){ cout << t[j][x] << endl; break; } x -= t[j].size(); } } } }

Compilation message (stderr)

collider.cpp: In function 'int main()':
collider.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if (x < t[j].size()){
      |             ~~^~~~~~~~~~~~~
collider.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if (y <= t[j].size()){
      |             ~~^~~~~~~~~~~~~~
collider.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if (x < t[j].size()){
      |             ~~^~~~~~~~~~~~~
collider.cpp:33:42: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |           t[j].insert(t[j].begin() + y, p);
      |                                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...