Submission #66738030
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define LagaKar ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ook order_of_key //number of elements less than k
#define fbo find_by_order //k th element (0 index)
#define nline endl
#define YES cout<<"YES"<<nline
#define NO cout<<"NO"<<nline
#define Yes cout<<"Yes"<<nline
#define No cout<<"No"<<nline
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#define precise(ans) cout<<fixed<<setprecision(15)<<ans
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define Tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define Sz(x) ((ll)(x).size())
#define All(x) x.begin(), x.end()
#define Allr(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(All(x))
#define MIN(x) *min_element(All(x))
#define SUM(x) accumulate(All(x), 0LL)
#define CNT(x) __builtin_popcountll(x)
//##################################################################################################################
typedef long long ll; typedef unsigned long long ull; typedef long double lld;
typedef pair<ll, ll> pl; typedef vector<ll> vl;typedef vector<vl> vvl;
typedef vector<pl> vpl; template <typename T> using prq_mx = priority_queue<T>;
template <typename T> using prq_mn = priority_queue<T, vector<T>, greater<T>>;
//------------------------------------------------------------------------------------------------------------
template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename R> using o_map = tree<T, R, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using o_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class Fun> class y_combinator_result {
Fun fun_;
public:
template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); }
};
template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); }
//********************************************************************************************************************
#ifdef hydracody
#include </home/anurag/Desktop/cpc/debug.h>
#else
#define debug(x)
#endif
//------------------------------------------------------------------------------------------------------------
const double eps=1e-9;const ll INF=(ll)1e9;const ll inf64=2e18;const ll INF64=9e18;
#define PI 3.1415926535897932384626
#define MOD 998244353
#define MOD1 1000000007
#define MOD2 1000000009
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
ll power(ll x,ll y, ll p){if(y==0)return 1;ll res = 1;x = x % p;if (x == 0) return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
ll pinv(ll a, ll m){ return power(a, m - 2, m); }
ll logceil(ll x){ll s=0;while(x>0){s++;x=x/2;}return s;}
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, pinv(b, m), m) + m) % m;} //only for prime m
ll phin(ll n) {ll number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0) n /= 2;} for (ll i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))
ll getRandomNumber(ll l, ll r) {return uniform_int_distribution<ll>(l, r)(rng);}
void starter(ll t) {cout << "Case #" << t << ": ";}
void starter1(ll t) {cerr << "Case #" << t << ": ";}
void compress(vector<ll>& vs){sort(vs.begin(),vs.end());vs.resize(unique(vs.begin(), vs.end()) - vs.begin());}
/////////////////////////////////////////////////////////////////////////////////////////////////
// **Stay calm ,Believe in YOURSELF,Never give UP
// **Not Everyday is Yours
void chal(){
ll n,q;
cin>>n>>q;
vl aa(n);
fo(i,n)aa[i]=i+1;
ll k=0;
while(q--){
ll ty;
cin>>ty;
if(ty==1){
ll p,x;
cin>>p>>x;
p--;
p=(p+(k%n))%n;
aa[p]=x;
}else if(ty==2){
ll p;
cin>>p;
p--;
p=(p+(k%n))%n;
cout<<aa[p]<<nline;
}else{
ll k1;
cin>>k1;
k+=k1;
}
// debug(aa);
}
cout<<nline;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int32_t main() {
LagaKar;
#ifdef hydracody
freopen("input.txt", "r", stdin); freopen("output1.txt", "w", stdout); freopen("error.txt", "w", stderr);
#endif
ll t; t = 1;
// cin>>t;
for (ll i = 1; i <= t; i++) {
// starter(i);
chal();
}
return 0;
}
/*
cmd->g++ code1.cpp ./a.out
*/
Submission Info
Submission Time |
|
Task |
C - Rotatable Array |
User |
Hydracody |
Language |
C++ 20 (gcc 12.2) |
Score |
300 |
Code Size |
5880 Byte |
Status |
AC |
Exec Time |
333 ms |
Memory |
11148 KiB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt |
All |
sample_01.txt, sample_02.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
1 ms |
3628 KiB |
sample_02.txt |
AC |
5 ms |
10888 KiB |
test_01.txt |
AC |
1 ms |
3496 KiB |
test_02.txt |
AC |
1 ms |
3636 KiB |
test_03.txt |
AC |
1 ms |
3348 KiB |
test_04.txt |
AC |
136 ms |
11064 KiB |
test_05.txt |
AC |
139 ms |
10984 KiB |
test_06.txt |
AC |
144 ms |
11148 KiB |
test_07.txt |
AC |
143 ms |
11020 KiB |
test_08.txt |
AC |
143 ms |
11004 KiB |
test_09.txt |
AC |
146 ms |
10900 KiB |
test_10.txt |
AC |
49 ms |
3496 KiB |
test_11.txt |
AC |
84 ms |
3636 KiB |
test_12.txt |
AC |
30 ms |
3632 KiB |
test_13.txt |
AC |
309 ms |
3964 KiB |
test_14.txt |
AC |
149 ms |
11012 KiB |
test_15.txt |
AC |
122 ms |
3492 KiB |
test_16.txt |
AC |
151 ms |
3436 KiB |
test_17.txt |
AC |
247 ms |
3584 KiB |
test_18.txt |
AC |
75 ms |
7396 KiB |
test_19.txt |
AC |
50 ms |
11072 KiB |
test_20.txt |
AC |
294 ms |
3636 KiB |
test_21.txt |
AC |
125 ms |
3500 KiB |
test_22.txt |
AC |
126 ms |
3612 KiB |
test_23.txt |
AC |
64 ms |
3496 KiB |
test_24.txt |
AC |
181 ms |
11140 KiB |
test_25.txt |
AC |
269 ms |
3444 KiB |
test_26.txt |
AC |
26 ms |
3356 KiB |
test_27.txt |
AC |
300 ms |
3572 KiB |
test_28.txt |
AC |
141 ms |
6132 KiB |
test_29.txt |
AC |
148 ms |
11120 KiB |
test_30.txt |
AC |
60 ms |
3464 KiB |
test_31.txt |
AC |
158 ms |
3520 KiB |
test_32.txt |
AC |
276 ms |
3488 KiB |
test_33.txt |
AC |
33 ms |
7452 KiB |
test_34.txt |
AC |
333 ms |
11044 KiB |
test_35.txt |
AC |
122 ms |
3640 KiB |
test_36.txt |
AC |
124 ms |
3472 KiB |
test_37.txt |
AC |
61 ms |
3636 KiB |
test_38.txt |
AC |
305 ms |
3492 KiB |
test_39.txt |
AC |
112 ms |
11092 KiB |
test_40.txt |
AC |
24 ms |
3588 KiB |
test_41.txt |
AC |
300 ms |
3624 KiB |
test_42.txt |
AC |
127 ms |
3392 KiB |
test_43.txt |
AC |
143 ms |
10480 KiB |
test_44.txt |
AC |
147 ms |
11120 KiB |