Submission #673919

# Submission time Handle Problem Language Result Execution time Memory
673919 2022-12-22T12:04:20 Z Cutebol Collider (IZhO11_collider) C++17
100 / 100
440 ms 1304 KB
#include <bits/stdc++.h>
 
using namespace std;
 
void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
#define Scaramouche ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
#define int long long
#define itn int
#define endl "\n"
#define ff first
#define ss second
   
const int N = 2e5 + 5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e9 ;

int n , m ;
int a[N] ;

void solve(){
	
	cin >> n >> m ;
	vector <char> vec(n) ;
	for ( auto &i : vec ) cin >> i ;
	while ( m -- ){
		char tt ;
		cin >> tt ;
		if ( tt == 'a' ){
			int x , y ;
			cin >> x >> y ;
			x -- , y -- ;
			char temp = vec[x] ;
			vec.erase( vec.begin() + x ) ;
			vec.insert(vec.begin() + y , temp ) ;
		}
		else{
			int x ;
			cin >> x ;
			x -- ;
			cout << vec[x] << '\n' ;
		}
	}
	
}
 
signed main(){
//  fopn("blocks") ;
    Scaramouche ;
    int t = 1 ;
//    	cin >> t ;
    while ( t -- ) solve() ; 
}

Compilation message

collider.cpp: In function 'void fopn(std::string)':
collider.cpp:5:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
collider.cpp:5:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 13 ms 432 KB Output is correct
4 Correct 106 ms 1116 KB Output is correct
5 Correct 203 ms 1108 KB Output is correct
6 Correct 298 ms 1208 KB Output is correct
7 Correct 332 ms 1300 KB Output is correct
8 Correct 127 ms 1236 KB Output is correct
9 Correct 440 ms 1300 KB Output is correct
10 Correct 307 ms 1304 KB Output is correct