Submission #537949

#TimeUsernameProblemLanguageResultExecution timeMemory
537949GioChkhaidzeCollider (IZhO11_collider)C++14
0 / 100
1 ms468 KiB
#include <bits/stdc++.h> using namespace std; string s; int n, m, bs = 1000; vector < int > v[10003]; main () { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); cin >> n >> m >> s; for (int i = 0; i < s.size(); ++i) { v[i / bs].push_back(i); } int ms = (s.size() - 1) / bs + 1; for (int i = 1; i <= m; ++i) { char c; cin >> c; if (c == 'a') { int id = 0, l, r; cin >> l >> r; --l, --r; if (l <= r) --r; for (int b = 0; b < ms; ++b) { if (!v[b].size()) continue; if (v[b].size() <= l) { l -= v[b].size(); } else { id = v[b][l]; v[b].erase(v[b].begin() + l); break; } } for (int b = 0; b < ms; ++b) { if (!v[b].size()) continue; if (v[b].size() <= r) { r -= v[b].size(); } else { v[b].insert(v[b].begin() + r, id); break; } } } else if (c == 'q') { int x; cin >> x; --x; for (int b = 0; b < ms; ++b) { if (!v[b].size()) continue; if (v[b].size() <= x) { x -= v[b].size(); } else { cout << s[v[b][x]] << "\n"; break; } } } if (i % bs == 0) { vector < int > rec; for (int b = 0; b < ms; ++b) { for (int j = 0; j < v[b].size(); ++j) { rec.push_back(v[b][j]); } v[b].clear(); } for (int j = 0; j < rec.size(); ++j) { v[j / bs].push_back(rec[j]); } rec.clear(); } } }

Compilation message (stderr)

collider.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main () {
      | ^~~~
collider.cpp: In function 'int main()':
collider.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i < s.size(); ++i) {
      |                  ~~^~~~~~~~~~
collider.cpp:27:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     if (v[b].size() <= l) {
      |         ~~~~~~~~~~~~^~~~
collider.cpp:39:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     if (v[b].size() <= r) {
      |         ~~~~~~~~~~~~^~~~
collider.cpp:54:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |     if (v[b].size() <= x) {
      |         ~~~~~~~~~~~~^~~~
collider.cpp:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for (int j = 0; j < v[b].size(); ++j) {
      |                     ~~^~~~~~~~~~~~~
collider.cpp:72:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |    for (int j = 0; j < rec.size(); ++j) {
      |                    ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...