提出 #69775230


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const int MOD = 1E9 + 7;
const ll MODL = 7177111117717LL;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define MP make_pair
#define all(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define SZ(a) (int)(a).size()
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

#ifndef _MSC_VER
#ifndef _DEBUG
#pragma GCC target ("avx2")
#pragma GCC optimize "O3,omit-frame-pointer,inline"
#pragma GCC optimize ("unroll-loops")
#endif
#endif

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll lcm(ll a, ll b) { return a / __gcd(a,b) * b; }


#ifdef _DEBUG
    #include "c:/contests/libs/debug.h"
#else
    #define dbg(...) 0
#endif

void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

#define SI() (cout << "Yes\n")
#define NO() (cout << "No\n")

void solve(){
    int n,q;cin>>n>>q;
    vector<ll> a(n);
    FOR(i,n) cin>>a[i];
    for(int i=1;i<n;++i) a[i] += a[i-1];

    int rot = 0;
    while(q--){
        int tipo;cin>>tipo;
        if (tipo==2){
            int l,r;cin>>l>>r;
            l = (l+rot-1)%n;
            r = (r+rot-1)%n;
            ll ret = a[r];
            if (l<= r) ret -= (l?a[l-1]:0);
            else{
                ret += a[n-1] - a[l-1];
            }
            cout << ret << "\n";
        }else{
            int c;cin>>c;
            rot += c;
            if (rot >=n) rot -= n;
        }
    }
 }

int main() {
    READ(0);
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}

提出情報

提出日時
問題 C - Rotate and Sum Query
ユーザ carre
言語 C++ 20 (gcc 12.2)
得点 350
コード長 2103 Byte
結果 AC
実行時間 52 ms
メモリ 5164 KiB

コンパイルエラー

Main.cpp: In function ‘void READ(bool)’:
Main.cpp:42:16: warning: unused parameter ‘_local’ [-Wunused-parameter]
   42 | void READ(bool _local){
      |           ~~~~~^~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 350 / 350
結果
AC × 2
AC × 22
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3468 KiB
00_sample_01.txt AC 1 ms 3612 KiB
01_random_00.txt AC 1 ms 3480 KiB
01_random_01.txt AC 21 ms 3564 KiB
01_random_02.txt AC 29 ms 4136 KiB
01_random_03.txt AC 16 ms 4624 KiB
01_random_04.txt AC 28 ms 3540 KiB
01_random_05.txt AC 40 ms 4676 KiB
01_random_06.txt AC 26 ms 3524 KiB
01_random_07.txt AC 41 ms 4668 KiB
01_random_08.txt AC 35 ms 4056 KiB
01_random_09.txt AC 40 ms 4676 KiB
01_random_10.txt AC 34 ms 3876 KiB
01_random_11.txt AC 41 ms 4584 KiB
01_random_12.txt AC 26 ms 4724 KiB
01_random_13.txt AC 26 ms 4688 KiB
01_random_14.txt AC 51 ms 5000 KiB
01_random_15.txt AC 52 ms 4984 KiB
01_random_16.txt AC 47 ms 4668 KiB
01_random_17.txt AC 32 ms 4696 KiB
01_random_18.txt AC 44 ms 5164 KiB
01_random_19.txt AC 34 ms 4700 KiB