Please sign in first.
Submission #48934505
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll MOD=998244353;
// head
const int N=5e5+5;
vector<vector<int>> tree(N);
int last[N];
map<int,int> sav;
int nam[N];
signed main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
int q;cin>>q;
int now=0;
int head=0;
nam[0]=0;
while(q--)
{
string s;cin>>s;
if(s=="ADD"){
int tmp;cin>>tmp;
nam[++head]=tmp;
tree[now].pb(head);
last[head]=now;
now=head;
}
else if(s=="DELETE"){
now=last[now];
}
else if(s=="SAVE"){
int x;cin>>x;
sav[x]=now;
}
else {
int x;cin>>x;
now=sav[x];
}
if(now==0) cout<<-1<<" ";
else cout<<nam[now]<<" ";
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Notebook |
| User | gangbengr |
| Language | C++ 20 (gcc 12.2) |
| Score | 500 |
| Code Size | 945 Byte |
| Status | AC |
| Exec Time | 412 ms |
| Memory | 46152 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, example0.txt, example1.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 101 ms | 40652 KiB |
| 001.txt | AC | 45 ms | 14896 KiB |
| 002.txt | AC | 412 ms | 46104 KiB |
| 003.txt | AC | 406 ms | 46152 KiB |
| 004.txt | AC | 336 ms | 30552 KiB |
| 005.txt | AC | 258 ms | 33920 KiB |
| 006.txt | AC | 211 ms | 35960 KiB |
| 007.txt | AC | 161 ms | 37516 KiB |
| 008.txt | AC | 121 ms | 39072 KiB |
| 009.txt | AC | 181 ms | 26992 KiB |
| 010.txt | AC | 153 ms | 30420 KiB |
| 011.txt | AC | 135 ms | 32932 KiB |
| 012.txt | AC | 118 ms | 35568 KiB |
| 013.txt | AC | 107 ms | 38128 KiB |
| 014.txt | AC | 83 ms | 28936 KiB |
| 015.txt | AC | 77 ms | 28864 KiB |
| 016.txt | AC | 88 ms | 28872 KiB |
| 017.txt | AC | 77 ms | 28900 KiB |
| 018.txt | AC | 76 ms | 28940 KiB |
| 019.txt | AC | 84 ms | 28880 KiB |
| 020.txt | AC | 82 ms | 28896 KiB |
| 021.txt | AC | 77 ms | 28904 KiB |
| 022.txt | AC | 83 ms | 28896 KiB |
| 023.txt | AC | 84 ms | 28820 KiB |
| 024.txt | AC | 226 ms | 33780 KiB |
| 025.txt | AC | 152 ms | 29388 KiB |
| 026.txt | AC | 29 ms | 17828 KiB |
| 027.txt | AC | 89 ms | 21344 KiB |
| 028.txt | AC | 90 ms | 21320 KiB |
| 029.txt | AC | 91 ms | 21264 KiB |
| 030.txt | AC | 92 ms | 21244 KiB |
| 031.txt | AC | 92 ms | 21300 KiB |
| 032.txt | AC | 92 ms | 21264 KiB |
| 033.txt | AC | 92 ms | 21336 KiB |
| 034.txt | AC | 93 ms | 21216 KiB |
| 035.txt | AC | 92 ms | 21284 KiB |
| 036.txt | AC | 89 ms | 21208 KiB |
| 037.txt | AC | 91 ms | 21344 KiB |
| 038.txt | AC | 91 ms | 21312 KiB |
| 039.txt | AC | 92 ms | 21248 KiB |
| 040.txt | AC | 93 ms | 21364 KiB |
| 041.txt | AC | 77 ms | 23148 KiB |
| 042.txt | AC | 80 ms | 23140 KiB |
| 043.txt | AC | 80 ms | 23132 KiB |
| example0.txt | AC | 8 ms | 14900 KiB |
| example1.txt | AC | 6 ms | 14940 KiB |