Submission #337873

# Submission time Handle Problem Language Result Execution time Memory
337873 2020-12-22T04:23:00 Z beksultan04 Collider (IZhO11_collider) C++14
100 / 100
938 ms 3552 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int dp[201][140001],q[N],n;
main(){
    int i,n,m;
    scan2(n,m)
    string s;
    cin>>s;
    vector <char> v;
    for (i=0;i<n;++i){
        v.pb(s[i]);
    }
    while (m--){
        char t;
        cin>>t;
        if (t == 'q'){
            int x;
            scan1(x)
            x--;
            cout <<v[x]<<"\n";
        }
        else {
            int x,y;
            scan2(x,y)
            char c = v[x-1];
            v.erase(v.begin()+x-1);
            v.insert(v.begin()+y-1,c);
        }
    }
}







Compilation message

collider.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main(){
      |      ^
collider.cpp: In function 'int main()':
collider.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
collider.cpp:23:5: note: in expansion of macro 'scan2'
   23 |     scan2(n,m)
      |     ^~~~~
collider.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
collider.cpp:35:13: note: in expansion of macro 'scan1'
   35 |             scan1(x)
      |             ^~~~~
collider.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
collider.cpp:41:13: note: in expansion of macro 'scan2'
   41 |             scan2(x,y)
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 10 ms 364 KB Output is correct
3 Correct 24 ms 876 KB Output is correct
4 Correct 258 ms 2724 KB Output is correct
5 Correct 456 ms 2724 KB Output is correct
6 Correct 660 ms 2976 KB Output is correct
7 Correct 755 ms 3424 KB Output is correct
8 Correct 317 ms 3424 KB Output is correct
9 Correct 938 ms 3424 KB Output is correct
10 Correct 612 ms 3552 KB Output is correct