提出 #58943111
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
using ll = long long;
int n, q;
int v[101][2];
int rig(int a, int b, int op){
int cnt = 0;
while (a != b){
a++;cnt++;
if (a > n) a = 1;
if (v[a][op ^ 1]) return -1;
}
return cnt;
}
int lef(int a, int b, int op){
int cnt = 0;
while (a != b){
a--;cnt++;
if (a < 1) a = n;
if (v[a][op ^ 1]) return -1;
}
return cnt;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>q;
v[1][0] = v[2][1] = true;
int pos[2] = {1, 2};
int ans = 0;
while(q--){
char c;cin>>c;
int op = (c == 'L' ? 0 : 1);
int k; cin>>k;
int ll = lef(pos[op], k, op);
int rr = rig(pos[op], k, op);
ans += max(ll, rr);
v[pos[op]][op] = 0;
pos[op] = k;
v[pos[op]][op] = 1;
}
cout<<ans;
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - Hands on Ring (Easy) |
| ユーザ | Vermeil |
| 言語 | C++ 17 (gcc 12.2) |
| 得点 | 250 |
| コード長 | 1010 Byte |
| 結果 | AC |
| 実行時間 | 1 ms |
| メモリ | 3568 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 250 / 250 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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_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, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3420 KiB |
| 00_sample_01.txt | AC | 1 ms | 3496 KiB |
| 00_sample_02.txt | AC | 1 ms | 3492 KiB |
| 01_random_00.txt | AC | 1 ms | 3464 KiB |
| 01_random_01.txt | AC | 1 ms | 3368 KiB |
| 01_random_02.txt | AC | 1 ms | 3492 KiB |
| 01_random_03.txt | AC | 1 ms | 3568 KiB |
| 01_random_04.txt | AC | 1 ms | 3400 KiB |
| 01_random_05.txt | AC | 1 ms | 3500 KiB |
| 01_random_06.txt | AC | 1 ms | 3436 KiB |
| 01_random_07.txt | AC | 1 ms | 3496 KiB |
| 01_random_08.txt | AC | 1 ms | 3564 KiB |
| 01_random_09.txt | AC | 1 ms | 3496 KiB |
| 01_random_10.txt | AC | 1 ms | 3500 KiB |
| 01_random_11.txt | AC | 1 ms | 3408 KiB |
| 01_random_12.txt | AC | 1 ms | 3492 KiB |
| 01_random_13.txt | AC | 1 ms | 3368 KiB |
| 01_random_14.txt | AC | 1 ms | 3464 KiB |
| 01_random_15.txt | AC | 1 ms | 3568 KiB |
| 02_handmade_00.txt | AC | 1 ms | 3396 KiB |
| 02_handmade_01.txt | AC | 1 ms | 3488 KiB |
| 02_handmade_02.txt | AC | 1 ms | 3500 KiB |
| 02_handmade_03.txt | AC | 1 ms | 3404 KiB |
| 02_handmade_04.txt | AC | 1 ms | 3504 KiB |