답안 #90096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90096 2018-12-20T08:04:34 Z YottaByte 입자 가속기 (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()
      ^
# 결과 실행 시간 메모리 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 -