提出 #61801926
ソースコード 拡げる
#ifndef ATCODER // AtCoder 環境でない場合はデバッグモードを有効にする. コンパイルにすごく時間がかかる!
#define _GLIBCXX_DEBUG // out of rangeを検出してくれる。#include<bits/stdc++.h>の前に記述する必要あり
#endif
#include<bits/stdc++.h>
using namespace std;
struct IOSetup {
IOSetup() {
// 実行が高速化するコード
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
// 小数点以下10桁まで(四捨五入)
cout << fixed << setprecision(10);
}
} iosetup;
#define rep(i, n) for (long long i = 0; i < n; i++)
#define rep2(i, a, b) for (long long i = a; i < b; i++)
#define rrep(i, b, a) for (long long i = b; i > a; i--)
#define rep3(i, a, b, d) for (long long i = a; i < b; i+=d)
#define rrep3(i, b, a, d) for (long long i = b; i > a; i-=d)
#define between(x, a, b) (((a) <= (x)) && ((x) < (b)))
// Template function to print various container types
template<typename Container>
void print(const Container& a) {
cout << "{";
bool first = true;
for (const auto& i : a) {
if (!first) {
cout << ",";
}
cout << i;
first = false;
}
cout << "}" << endl;
}
// Template function to print 2D vector
template<typename T>
void printvec2d(const vector<vector<T>>& a) {
size_t rows = a.size();
for (size_t i = 0; i < rows; ++i) {
print(a[i]);
}
}
// Template function to print 3D vector
template<typename T>
void printvec3d(const vector<vector<vector<T>>>& a) {
size_t depth = a.size();
for (size_t i = 0; i < depth; ++i) {
printvec2d(a[i]);
cout << endl;
}
}
int main() {
int q;
cin >> q;
long long offset = 0;
int now = 0;
vector<pair<long long, long long>> p;
vector<long long> ans;
rep(_, q) {
long long t; long long l;
cin >> t;
if (t == 1) {
cin >> l;
if (p.size() == 0) {
p.push_back({0LL, l - 1});
}
else {
auto [pre_head, pre_tail] = p.back();
p.push_back({pre_tail + 1, pre_tail + l});
}
}
if (t == 2) {
auto [first_head, first_tail] = p[now];
offset += first_tail - first_head + 1;
now++;
}
if (t == 3) {
long long k;
cin >> k;
ans.push_back(p[now + k - 1].first - offset);
}
}
for (auto& i : ans) {
cout << i << endl;
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Snake Queue |
| ユーザ | kazuki00 |
| 言語 | C++ 23 (gcc 12.2) |
| 得点 | 300 |
| コード長 | 2636 Byte |
| 結果 | AC |
| 実行時間 | 173 ms |
| メモリ | 11580 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 02_min_00.txt, 02_min_01.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3496 KiB |
| 00_sample_01.txt | AC | 1 ms | 3420 KiB |
| 00_sample_02.txt | AC | 1 ms | 3480 KiB |
| 01_test_00.txt | AC | 2 ms | 3440 KiB |
| 01_test_01.txt | AC | 2 ms | 3504 KiB |
| 01_test_02.txt | AC | 3 ms | 3444 KiB |
| 01_test_03.txt | AC | 4 ms | 3588 KiB |
| 01_test_04.txt | AC | 1 ms | 3632 KiB |
| 01_test_05.txt | AC | 4 ms | 3588 KiB |
| 01_test_06.txt | AC | 167 ms | 6820 KiB |
| 01_test_07.txt | AC | 81 ms | 4940 KiB |
| 01_test_08.txt | AC | 166 ms | 6864 KiB |
| 01_test_09.txt | AC | 144 ms | 5868 KiB |
| 01_test_10.txt | AC | 166 ms | 6840 KiB |
| 01_test_11.txt | AC | 67 ms | 4660 KiB |
| 01_test_12.txt | AC | 166 ms | 6824 KiB |
| 01_test_13.txt | AC | 63 ms | 4544 KiB |
| 01_test_14.txt | AC | 165 ms | 6820 KiB |
| 01_test_15.txt | AC | 116 ms | 6408 KiB |
| 01_test_16.txt | AC | 112 ms | 6500 KiB |
| 01_test_17.txt | AC | 112 ms | 6456 KiB |
| 01_test_18.txt | AC | 75 ms | 7208 KiB |
| 01_test_19.txt | AC | 70 ms | 7196 KiB |
| 01_test_20.txt | AC | 71 ms | 7380 KiB |
| 01_test_21.txt | AC | 71 ms | 7152 KiB |
| 01_test_22.txt | AC | 163 ms | 8492 KiB |
| 01_test_23.txt | AC | 173 ms | 8668 KiB |
| 01_test_24.txt | AC | 30 ms | 11396 KiB |
| 01_test_25.txt | AC | 22 ms | 11580 KiB |
| 01_test_26.txt | AC | 30 ms | 11444 KiB |
| 01_test_27.txt | AC | 19 ms | 7400 KiB |
| 02_min_00.txt | AC | 1 ms | 3496 KiB |
| 02_min_01.txt | AC | 1 ms | 3620 KiB |