Submission #00130


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0), ios::sync_with_stdio(false);
int l;cin>>l;
char t;int a;
deque<int>d;
vector<int>b(101,0);
for(int i=0;i<l;i++){
cin>>t>>a;
if(t=='L'){
if(a>=0){
d.push_front(a);
b[a]++;
if(b[a]>=2){
cout<<i+1<<"\n";
return 0;
}
}else{
b[abs(a)]--;
if(b[abs(a)]<=-1){
cout<<i+1<<"\n";
return 0;
}
if(abs(a)!=d.front()){
cout<<i+1<<"\n";
return 0;
}
d.pop_front();
}
}else{
if(a>=0){
d.push_back(a);
b[a]++;
if(b[a]>=2){
cout<<i+1<<"\n";
return 0;
}
}else{
b[abs(a)]--;
if(b[abs(a)]<=-1){
cout<<i+1<<"\n";
return 0;
}
if(abs(a)!=d.back()){
cout<<i+1<<"\n";
return 0;
}
d.pop_back();
}
}
}
cout<<"OK\n";
}

ステータス

項目 データ
問題 0015 - いぬのあな
ユーザー名 ei2331
投稿日時 2023-11-14 16:44:57
言語 C++17
状態 Accepted
得点 50
ソースコード長 1058 Byte
最大実行時間 50 ms
最大メモリ使用量 716 KB

セット

セット 得点 Cases
1 ALL 50 / 50 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in-01.txt AC 44 ms 348 KB
1
in-02.txt AC 41 ms 556 KB
1
in-03.txt AC 50 ms 640 KB
1
in-04.txt AC 37 ms 716 KB
1
in-05.txt AC 18 ms 668 KB
1
in-06.txt AC 19 ms 488 KB
1
in-07.txt AC 16 ms 572 KB
1
in-08.txt AC 17 ms 520 KB
1
in-09.txt AC 15 ms 476 KB
1
in-10.txt AC 20 ms 552 KB
1