#20963: 為何RE


simon930423@gmail.com (Tsubasa_)

學校 : 不指定學校
編號 : 106748
來源 : [210.60.158.82]
最後登入時間 :
2019-10-03 16:58:19
d718. Waiting In Line | From: [1.161.113.117] | 發表日期 : 2020-03-22 13:06

#include <bits/stdc++.h>
using namespace std;

int p_in_gid[1000005];
int gc[1005];

int main(){
int n, l = 1;
while(cin >> n){
list<int> line;
list<int>::iterator g_end[1000];
memset(gc, 0, sizeof(g_end));
memset(p_in_gid, -1, sizeof(p_in_gid));

for(int i = 0, m; i < n; i++){
cin >> m;
for(int j = 0, p; j < m; j++){
cin >> p;
p_in_gid[p] = i;
}
}
cout << "Line #" << l++ << '\n';
string str;
while(cin >> str, str[0] != 'S'){
if(str[0] == 'E'){
int id;
cin >> id;

int i = p_in_gid[id];
if(i == -1){
line.emplace_back(id);
}else if(gc[i] == 0){
line.emplace_back(id);
g_end[i] = --line.end();
gc[i]++;
}else{
gc[i]++;
g_end[i] = line.insert(++g_end[i], id);
}
}else if(str[0] == 'D'){
cout << line.front() << '\n';

int i = p_in_gid[line.front()];
if(i > -1) gc[i]--;

line.erase(line.begin());

}
}
}
}

 
 
ZeroJudge Forum