Submission #00109
ソースコード
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 55 56 57 58 59 60 61 62 63 64 65 | #include<bits/stdc++.h> using namespace std; using vecint = vector< int >; using vec2int = vector<vector< int >>; using vecstr = vector<string>; using vecll = vector< long long >; using vec2ll = vector<vector< long long >>; #define ll long long #define ull unsigned long long #define rin(a) for(auto& b : a) cin >> b #define so(a) stable_sort(a.begin(),a.end()) #define sor(a) stable_sort(a.begin(),a.end(),greater<int>()) #define show(a) for(auto& b : a) cout << b ; cout << endl #define NOFIND string::npos #define INF 1e18 int main(){ int l; cin >> l; vecint d(l); vector< char > t(l); for ( int i=0 ; i<l ; i++){ cin >> t[i] >> d[i]; } deque< int > ana; for ( int i=0 ; i<l ; i++){ if (t[i]== 'L' ){ if (d[i]>=0){ for ( int j=0 ; j<ana.size() ; j++){ if (ana[j]==d[i]){ cout << i+1 << endl; return (0); } } ana.push_front(d[i]); } else { if (ana.front() == -d[i]){ ana.pop_front(); } else { cout << i+1 << endl; return (0); } } } else { if (d[i]>=0){ for ( int j=0 ; j<ana.size() ; j++){ if (ana[j]==d[i]){ cout << i+1 << endl; return (0); } } ana.push_back(d[i]); } else { if (ana.back() == -d[i]){ ana.pop_back(); } else { cout << i+1 << endl; return (0); } } } } cout << "OK\n" ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0015 - いぬのあな |
ユーザー名 | ei2222 |
投稿日時 | 2023-11-13 21:54:59 |
言語 | C++17 |
状態 | Accepted |
得点 | 50 |
ソースコード長 | 1857 Byte |
最大実行時間 | 23 ms |
最大メモリ使用量 | 564 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 50 / 50 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in-01.txt | AC | 23 ms | 476 KB |
1
|
in-02.txt | AC | 23 ms | 564 KB |
1
|
in-03.txt | AC | 21 ms | 404 KB |
1
|
in-04.txt | AC | 20 ms | 504 KB |
1
|
in-05.txt | AC | 22 ms | 468 KB |
1
|
in-06.txt | AC | 23 ms | 432 KB |
1
|
in-07.txt | AC | 20 ms | 532 KB |
1
|
in-08.txt | AC | 19 ms | 500 KB |
1
|
in-09.txt | AC | 22 ms | 464 KB |
1
|
in-10.txt | AC | 23 ms | 556 KB |
1
|