Submission #90096

# Submission time Handle Problem Language Result Execution time Memory
90096 2018-12-20T08:04:34 Z YottaByte Collider (IZhO11_collider) C++14
0 / 100
2000 ms 8160 KB
#include <iostream>
using namespace std;

#define pb push_back
#define mk make_pair
#define fr first
#define sc second

main()
{
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	while(q--)
	{
		char t; cin >> t;
		if(t == 'q')
		{
			int k; cin >> k;
			cout << s[k - 1] << endl;
		}
		else
		{
			int l, r;
			cin >> l >> r;
			l--;
			r--;
			char x = s[l];
			if(l < r)
			{
				//cout << x << " " << l << " " << r << endl;
				s = s.substr(0, l) + s.substr(l + 1, abs(r - l)) + x + s.substr(r + 1, s.size() - r);
			}
			else
			{
				s = s.substr(0, r) + x + s.substr(r, abs(r - l)) + s.substr(l + 1, s.size() - l);
			}
		}
		//cout << s << endl;
	}
}
/*

14 3

xxyxyzxxzxzyyzy
xxyxyzxxzxzyyzy

*/

Compilation message

collider.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 21 ms 612 KB Output is correct
3 Correct 143 ms 1404 KB Output is correct
4 Correct 1104 ms 7032 KB Output is correct
5 Execution timed out 2040 ms 8160 KB Time limit exceeded
6 Halted 0 ms 0 KB -