Submission #69658668


Source Code Expand

  //#include "atcoder/modint"
  #pragma GCC optimize("Ofast")
  #include "atcoder/all"
  #include <bits/stdc++.h>
  #include  <string>
  using namespace std;
  using namespace atcoder;
  #define int long long
    template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
  template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
  //const int MOD =1e9+7;
  //constexpr int MOD =10;
  constexpr int MOD =998244353;
  const long long M1=167772161,M2=469762049,M3=1224736769;
  //const int MOD =31607;
  using mint = static_modint<MOD>;
  //using mint = double;
  //using mint = modint;
  ostream& operator << (ostream& ost, const mint& m){ost << m.val();return ost;}
  istream& operator >> (istream& ost,  mint& m){int a;ost >> a;m=a;return ost;}
  double time_limit = 100.0,start_temp=0.01,end_temp=0.0;
  std::mt19937 rng(std::random_device{}()); 

  signed main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int n,q;
    cin>>n>>q;
    int a[n+1]={};
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=n-1;i>=0;i--)a[i]+=a[i+1];
    int s=0,t,c;
    for(int i=0;i<q;i++){
      cin>>t;
      if(t==1){
        cin>>c;
        s=(s+c)%n;
      }else{
        int l,r;
        cin>>l>>r;l--;
        l=((l+s)%n);
        r=(r-1+s)%n+1;
        
        if(l<r){
          cout<<a[l]-a[r]<<"\n";
        }else{
          cout<<a[l]+a[0]-a[r]<<"\n";
        }
      }
    }




  
 
   

  }

Submission Info

Submission Time
Task C - Rotate and Sum Query
User yatuba
Language C++ 20 (gcc 12.2)
Score 350
Code Size 1532 Byte
Status AC
Exec Time 341 ms
Memory 5320 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 2
AC × 22
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3532 KiB
00_sample_01.txt AC 1 ms 3524 KiB
01_random_00.txt AC 1 ms 3620 KiB
01_random_01.txt AC 145 ms 3632 KiB
01_random_02.txt AC 161 ms 4524 KiB
01_random_03.txt AC 67 ms 5128 KiB
01_random_04.txt AC 169 ms 3684 KiB
01_random_05.txt AC 220 ms 5116 KiB
01_random_06.txt AC 163 ms 3588 KiB
01_random_07.txt AC 220 ms 5064 KiB
01_random_08.txt AC 199 ms 4644 KiB
01_random_09.txt AC 220 ms 5016 KiB
01_random_10.txt AC 196 ms 4436 KiB
01_random_11.txt AC 220 ms 5176 KiB
01_random_12.txt AC 97 ms 5320 KiB
01_random_13.txt AC 97 ms 5176 KiB
01_random_14.txt AC 340 ms 5188 KiB
01_random_15.txt AC 341 ms 5180 KiB
01_random_16.txt AC 291 ms 5196 KiB
01_random_17.txt AC 147 ms 5128 KiB
01_random_18.txt AC 325 ms 5212 KiB
01_random_19.txt AC 205 ms 5200 KiB