提出 #69887319
ソースコード 拡げる
// PriashisG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// Typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;
/*
greater<int> for large to small
less_equal for not unique
finding sz-th element --> os.find_by_order(sz); // O(log n)
finding the number of elements smaller than x --> os.order_by_szey(x); // O(log n)
os.erase(x);
*/
// Macros
#define PB push_back
#define IN insert
#define all(x) x.begin(), x.end()
#define trav(i, a) for (auto &i : a)
#define GCD __gcd
#define F first
#define S second
#define endl '\n'
#define LB lower_bound
#define UB upper_bound
#define DEBUG(i) cout << "DEBUG " << i << "\n";
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define GT(x) greater<x>()
#define setpre(n) fixed << setprecision(n)
#define SZ(x) x.size()
// Functions
template <typename T> void pv(vector<T> &a){
for (T u : a) cout << u << ' ';
cout << '\n';
}
template <typename T> void pv2(vector<vector<T>> &a){
trav(aa, a) pv(aa);
}
template <typename T, typename U> void pvp( vector<pair<T, U>> &a){
trav(p, a) cout << "(" << p.F << ", " << p.S << ") ";
cout << '\n';
}
// Constants
const ll MOD7 = 1e9 + 7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
// Custom Functions
void fast(){
ios::sync_with_stdio(false); cin.tie(0);
}
ll LCM(ll a, ll b){
return (a * b) / GCD(a, b);
}
// Custom Comparator
bool cmp(const pair<ll, ll>& x, const pair<ll, ll>& y){
if (x.F == y.F) return x.S > y.S;
else return x.F < y.F;
}
// Global Variables
void solve(ll tc){
int n, q;
cin >> n >> q;
vll v(n + 3, 0ll);
for (int i = 1; i <= n; i++) cin >> v[i];
for (int i = 1; i <= n; i++) v[i] += v[i - 1];
int shuru = 1;
while (q--){
int type;
cin >> type;
if (type == 1){
int c;
cin >> c;
if (shuru + c <= n) shuru += c;
else shuru = shuru + c - n;
// DEBUG(shuru)
}
else{
int l, r;
cin >> l >> r;
ll ans = 0;
int start = shuru + l - 1;
if (start > n) start -= n;
int end = shuru + r - 1;
if (end > n) end -= n;
// cout << start << ' ' << end << '\n';
if (start > end){
ans = v[n] - v[start - 1];
ans += v[end];
}
else ans = v[end] - v[start - 1];
cout << ans << '\n';
}
}
}
int main(void){
fast();
// precal();
// freopen("fenceplan.in", "r", stdin);
// freopen("fenceplan.out", "w", stdout);
ll t = 1;
int i = 1;
// cin >> t;
// for (ll i = 1; i <= t; i++)
solve(i);
}
提出情報
コンパイルエラー
Main.cpp: In function ‘void solve(ll)’:
Main.cpp:82:15: warning: unused parameter ‘tc’ [-Wunused-parameter]
82 | void solve(ll tc){
| ~~~^~
Main.cpp: In function ‘int main()’:
Main.cpp:136:8: warning: unused variable ‘t’ [-Wunused-variable]
136 | ll t = 1;
| ^
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
350 / 350 |
| 結果 |
|
|
| セット名 |
テストケース |
| 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 |
3492 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3564 KiB |
| 01_random_00.txt |
AC |
1 ms |
3616 KiB |
| 01_random_01.txt |
AC |
20 ms |
3400 KiB |
| 01_random_02.txt |
AC |
28 ms |
4004 KiB |
| 01_random_03.txt |
AC |
15 ms |
4600 KiB |
| 01_random_04.txt |
AC |
26 ms |
3624 KiB |
| 01_random_05.txt |
AC |
40 ms |
4644 KiB |
| 01_random_06.txt |
AC |
26 ms |
3628 KiB |
| 01_random_07.txt |
AC |
39 ms |
4660 KiB |
| 01_random_08.txt |
AC |
33 ms |
4116 KiB |
| 01_random_09.txt |
AC |
39 ms |
4604 KiB |
| 01_random_10.txt |
AC |
32 ms |
3804 KiB |
| 01_random_11.txt |
AC |
38 ms |
4688 KiB |
| 01_random_12.txt |
AC |
26 ms |
4532 KiB |
| 01_random_13.txt |
AC |
26 ms |
4632 KiB |
| 01_random_14.txt |
AC |
49 ms |
5000 KiB |
| 01_random_15.txt |
AC |
50 ms |
4892 KiB |
| 01_random_16.txt |
AC |
45 ms |
4652 KiB |
| 01_random_17.txt |
AC |
31 ms |
4636 KiB |
| 01_random_18.txt |
AC |
41 ms |
5140 KiB |
| 01_random_19.txt |
AC |
32 ms |
4628 KiB |