답안 #88154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88154 2018-12-04T05:44:05 Z abil 입자 가속기 (IZhO11_collider) C++14
0 / 100
2000 ms 8848 KB
/**
   Solution by Abil
**/
#include <bits/stdc++.h>

using namespace std;

main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int l, r;
    char ch;
    string s1,s2,s3;
    while(m--){
      cin >> ch;
      if(ch == 'a'){
        cin >> l >> r;
        if(l < r){
         s1 = s.substr(0,l - 1);
         s2 = s.substr(r);
         int p = r - l;
         s3 = s.substr(l,p);
         s3 =s3 + s[l - 1];
         s = s1 + s3 + s2;
        }
        else
        if(r < l){
          s1 = s.substr(0,r - 1);
          s2 = s.substr(l);
          int p = l - r;
          s3 = s.substr(r - 1,p);
          s3 =s[l - 1] + s3;
          s = s1 + s3 + s2;
        }
      }
      else{
        cin >> l;
        cout << s[l - 1] << endl;
      }
    }

    return 0;
}

Compilation message

collider.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 22 ms 640 KB Output is correct
3 Correct 200 ms 1700 KB Output is correct
4 Correct 1611 ms 7928 KB Output is correct
5 Execution timed out 2091 ms 8848 KB Time limit exceeded
6 Halted 0 ms 0 KB -