70分没过的点全部是RE求帮看看
查看原帖
70分没过的点全部是RE求帮看看
1303781
wwy123楼主2024/7/30 21:05
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 1e5+10;
i64 n, t, k, check[1000005], t1, ans;
queue<i64> tq;
struct Node {
	i64 ti, xi;
	struct Node *next;
};

struct QNode {
	struct Node *front;
	struct Node *rear;
};
struct QNode *Queue;
struct RNode {
	int Ti, Xi;
	bool tag;
};
inline void AddQ(i64 x){
	if(!Queue->front && !Queue->rear){
		struct Node *temp = (struct Node *)malloc(sizeof(struct Node));
		temp->ti = t;temp->xi = x;
		temp->next = Queue->front;
		Queue->front = temp;Queue->rear = temp;
	}
	else {
		struct Node *temp = (struct Node *)malloc(sizeof(struct Node));
		temp->ti = t;temp->xi = x;
		temp->next = Queue->rear->next;
		Queue->rear->next = temp;
		Queue->rear = temp;
	}
}

inline struct RNode PopQ(){
	if(!Queue->rear && !Queue->front){
		struct RNode ret;ret.Ti = -1;ret.Xi = -1;ret.tag = false;
		return ret;
	}
	else {
		struct RNode ret;
		struct Node *temp = Queue->front;
		Queue->front = Queue->front->next;
		ret.Ti = temp->ti;ret.Xi = temp->xi;
		ret.tag = true;
		free(temp);
		return ret;		
	}
}

inline struct RNode GetQ(){
	if(!Queue->rear && !Queue->front){
		struct RNode ret;ret.Ti = -1;ret.Xi = -1;ret.tag = false;
		return ret;
	}
	else {
		struct RNode ret;
		struct Node *temp = Queue->front;
		ret.Ti = temp->ti;ret.Xi = temp->xi;
		ret.tag = true;
		return ret;		
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	Queue = (struct QNode *)malloc(sizeof(struct QNode));
	Queue->front = NULL;Queue->rear = NULL;
	for (int i = 1;i <= n;i++){
		cin >> t >> k;
		tq.push(t);
		while (!tq.empty()){
			t1 = tq.front();
			if(t1+86400 <= t){
				while (GetQ().Ti == t1){
					struct RNode Ret = GetQ();
					check[Ret.Xi]--;
					if(!check[Ret.Xi]) ans--;
					PopQ();
				}
				tq.pop();
				continue;
			}
			else break;
		}
		while (k--){
			i64 x;cin >> x;
			AddQ(x);
			if(!check[x]++) ans++;
		}
		cout << ans << '\n';
	}	
	return 0;
}
2024/7/30 21:05
加载中...