QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#439439 | #8302. Incoming Asteroids | moyujiang | WA | 0ms | 16032kb | C++14 | 1.5kb | 2024-06-11 22:07:48 | 2024-06-11 22:07:49 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a),i##END=(b);i<=i##END;i++)
#define Rof(i,b,a) for(int i=(b),i##END=(a);i>=i##END;i--)
#define go(u) for(int i=head[u];i;i=nxt[i])
using namespace std;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
const int N=2e5+10;
int n,m,lst,o[N][3],Tag[N][3];
int idx,Y[N],d[N];
struct node{
int id,val;
bool operator < (const node &x) const {
return val<x.val;
}
};
multiset<node> s[N];
int tag[N];
bool check(int id){
int y=0;For(i,0,2)y+=tag[o[id][i]]-Tag[id][i];
return y>=Y[id];
}
void upd(int id){
For(i,0,2)Y[id]-=tag[o[id][i]]-Tag[id][i],Tag[id][i]=tag[o[id][i]];
For(i,0,2)s[o[id][i]].insert((node){idx,Y[id]/3+1+tag[o[id][i]]});
}
signed main(){
n=read(),m=read();while(m--){
int op=read();
if(op==1){
int y=read()^lst,k=read();
Y[++idx]=y;
For(j,1,k){
int x=read()^lst;
o[idx][j-1]=x;
Tag[idx][j-1]=tag[x];
s[x].insert((node){idx,y/3+1+tag[x]});
}
}else{
int x=read()^lst,y=read()^lst;vector<int> ans;
tag[x]+=y;while(!s[x].empty()&&tag[x]>=s[x].begin()->val){
int id=s[x].begin()->id;s[x].erase(s[x].begin());
if(!d[id]){
if(check(id))d[id]=1,ans.push_back(id);
else upd(id);
}
}printf("%d",lst=ans.size());for(int x:ans)printf(" %d",x);
puts("");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 16032kb
input:
3 5 1 5 3 1 2 3 2 2 1 1 2 2 1 2 2 3 1 2 1 3
output:
0 0 2 2 1
result:
wrong answer 3rd lines differ - expected: '2 1 2', found: '2 2 1'