Submission #337873

#TimeUsernameProblemLanguageResultExecution timeMemory
337873beksultan04Collider (IZhO11_collider)C++14
100 / 100
938 ms3552 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...