求助!
  • 板块学术版
  • 楼主Quartz_Blocks
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/6/27 20:42
  • 上次更新2024/6/28 07:46:34
查看原帖
求助!
1059176
Quartz_Blocks楼主2024/6/27 20:42

UVA540 RE\color{purple}RE on #1

#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <bits/stdc++.h>
#include <stack>
using namespace std;
struct team{
	int a[10010];
	int n;
};
struct teamqueue{
	queue <int> t;
};
int main(){
	int n;
	int sc = 1;
	while(cin >> n){
		if(n == 0) break;
		const int N = n+10;
		team a[N];
		int tong[1000010];
		for(int i = 1;i <= n;i++){
			cin >> a[i].n;
			for(int j = 1;j <= a[i].n;j++){
				cin >> a[i].a[j];
				tong[a[i].a[j]] = i;
			}
		}
		queue <int> t;
		bool flag[10010];
        for(int i = 1;i <= n;i++) flag[i] = false;
		teamqueue q[10010];
		string s;
		cout << "Scenario #" << sc << endl;
		while(cin >> s){
			if(s == "STOP"){
				break;
			}else if(s == "ENQUEUE"){
				int x;
				cin >> x;
				if(flag[tong[x]] == false){
					flag[tong[x]] = true;
					t.push(tong[x]);
                    //cout << "tp" << endl;
				}
				q[tong[x]].t.push(x);
			}
			if(s == "DEQUEUE"){
               // cout << t.empty() << endl;
				cout << q[t.front()].t.front() << endl;
				q[t.front()].t.pop();
				if(q[t.front()].t.empty()){
					t.pop();
				}
			}
		}
		sc++;
		cout << endl;
	}
	cout << endl;
	return 0;
}
2024/6/27 20:42
加载中...