QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717756#5188. 鬼街Southern_DynastyAC ✓6370ms1381084kbC++172.2kb2024-11-06 18:53:262024-11-06 18:53:27

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 18:53:27]
  • 评测
  • 测评结果:AC
  • 用时:6370ms
  • 内存:1381084kb
  • [2024-11-06 18:53:26]
  • 提交

answer

// test
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define mp make_pair
#define sec second
#define fir first
#define pii pair<int,int>
#define lowbit(i) i&-i
#define int long long
#define qingbai 666
using namespace std;
typedef long long ll;
const int N=1e5+5,M=105,inf=1e9+7,mo=998244353;
void read(int &p){
	int x=0,w=1;
	char ch=0;
	while(!isdigit(ch)){
		if(ch=='-')w=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	p=x*w;
}
int n,m;
vector<int>d[N];
struct node{
	int id,opid,targ;//监视器编号、阈值编号及报警阈值
	friend bool operator<(node x,node y){
		return x.targ>y.targ;
	}
};
priority_queue<node>q[N];
int cnt[N];
pii mon[N];
int stp[N],nop[N];
bool vis[N];
int gets(int x){
	int res=0;
	for(auto j:d[mon[x].fir])
	    res+=cnt[j];
	return res;
}
signed main(){
	read(n),read(m);
	rep(i,1,n){
		int x=i;
		rep(j,2,sqrt(i)){
			int cnt=0;
			while(x%j==0)
			    x/=j,cnt++;
			if(cnt!=0)d[i].push_back(j);
		}
		if(x!=1)d[i].push_back(x);
	}
	int lans=0,cntm=0;
	vector<int>ans;
	while(m--){
		int op,x,y;
		read(op),read(x),read(y),y^=lans;
		if(op==1){
			cntm++;
			if(!y){
				ans.push_back(cntm);
				continue;
			}
			int targ=(y-1)/d[x].size()+1;
			nop[cntm]++;
			for(auto i:d[x])
			    q[i].push((node){cntm,nop[cntm],targ+cnt[i]}),stp[cntm]+=cnt[i];
			mon[cntm]=mp(x,y+stp[cntm]);
		}
		else{
			for(auto i:d[x])
				cnt[i]+=y;
			for(auto i:d[x]){
				while(!q[i].empty()&&q[i].top().targ<=cnt[i]){
					node nw=q[i].top();
					q[i].pop();
					if(vis[nw.id])continue;
					if(nop[nw.id]!=nw.opid)continue;//懒惰删除 
					int nws=gets(nw.id);
					if(nws>=mon[nw.id].sec)vis[nw.id]=1,ans.push_back(nw.id);
					else{
						int ntg=(mon[nw.id].sec-nws-1)/d[mon[nw.id].fir].size()+1;
					    nop[nw.id]++;
						for(auto j:d[mon[nw.id].fir])
							q[j].push((node){nw.id,nop[nw.id],cnt[j]+ntg});
					}
				}
			}
			printf("%lld",(int)ans.size());
			sort(ans.begin(),ans.end());
			for(auto i:ans)
			    printf(" %lld",i);
			lans=ans.size();
			ans.clear();
			puts("");
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 10900kb

input:

20 9
1 10 2
0 5 0
0 6 1
0 7 1
0 15 1
1 12 3
0 8 0
1 5 0
0 8 2

output:

0
0
0
1 1
0
2 2 3

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 4ms
memory: 11260kb

input:

5000 5000
1 308 2924116129
1 3201 931426424
1 4398 709387999
0 609 2256581248
0 1566 1777416018
1 4709 1171183682
0 3770 752123966
1 1896 3894906376
0 230 3761076141
1 1345 676968476
1 3116 342409501
0 4948 3143999592
1 2186 2376352094
1 3892 3478048443
0 2773 2100852395
1 2894 2317216575
0 3378 211...

output:

2 2 3
1 1
0
0
2 5 7
0
0
0
1 11
1 4
3 8 9 10
0
0
0
5 13 14 15 17 19
0
0
2 18 20
0
2 16 22
5 6 21 23 24 25
0
0
2 27 29
1 28
2 26 30
0
0
0
0
0
0
1 33
0
0
2 31 32
0
0
2 35 36
0
0
1 37
0
0
0
0
1 39
1 40
0
0
1 42
0
0
2 34 43
0
0
4 44 46 48 49
2 50 51
0
0
1 52
0
2 45 53
0
0
0
3 54 56 59
2 57 61
0
0
0
0
0
0...

result:

ok 2569 lines

Test #3:

score: 0
Accepted
time: 99ms
memory: 17124kb

input:

100000 100000
0 88257 3347892307
1 75731 1809061227
0 16838 427131616
1 37901 3913929645
0 34652 2841091466
1 94967 1193577995
0 88669 2312699947
0 65963 2968268361
0 24727 3935129828
0 85199 4076952986
0 80409 4193957044
1 65125 3928747142
1 46471 976433442
0 40164 1210148974
0 66889 3862378511
1 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
2 7 8
1 9
0
1 12
1 11
2 10 13
6 4 15 16 18 20 21
1 23
0
1 17
0
0
0
1 30
0
0
1 24
0
5 26 28 31 32 34
1 36
1 37
0
0
4 27 29 38 39
2 40 42
5 3 43 45 47 48
2 33 41
1 46
3 49 50 51
0
0
1 52
3 14 44 54
0
0
0
0
0
0
0
3 57 58 60
0
11 55 56 62 63 65 66 67 68 69 70 71
0
0
1 72
0
0
3 ...

result:

ok 49859 lines

Test #4:

score: 0
Accepted
time: 260ms
memory: 30240kb

input:

100000 100000
1 100000 686376074
1 99999 1480169272
1 99998 3342696633
1 99997 3780400597
1 99996 987312141
1 99995 1940629988
1 99994 3882419811
1 99993 2620287406
1 99992 117147645
1 99991 4118056210
1 99990 1544011251
1 99989 2856008809
1 99988 1621361290
1 99987 3983397497
1 99986 1989759776
1 9...

output:

37 1777 4119 4466 7328 10001 10481 10796 11973 13694 13747 17453 18447 18452 18710 24307 24353 27219 27867 31925 32241 32807 35929 36485 36515 36920 37737 38555 39865 40243 41097 42861 44559 44895 45518 45572 48590 48809
30 2625 3410 4325 4643 4785 10441 13124 16215 19575 23229 24815 27493 29907 301...

result:

ok 50000 lines

Test #5:

score: 0
Accepted
time: 327ms
memory: 115628kb

input:

100000 100000
1 2 50000
1 4 50000
1 6 50000
1 8 50000
1 10 50000
1 12 50000
1 14 50000
1 16 50000
1 18 50000
1 20 50000
1 22 50000
1 24 50000
1 26 50000
1 28 50000
1 30 50000
1 32 50000
1 34 50000
1 36 50000
1 38 50000
1 40 50000
1 42 50000
1 44 50000
1 46 50000
1 48 50000
1 50 50000
1 52 50000
1 54...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 50000 lines

Test #6:

score: 0
Accepted
time: 95ms
memory: 16512kb

input:

100000 100000
1 71533 1624315381
0 89184 1624315381
1 93680 3158643236
0 66680 3158643236
1 93948 1261724001
0 59949 1261724001
1 42374 1643731476
0 84748 1643731476
1 88256 2309789107
0 38136 2309789107
1 51927 2589008727
0 91100 2589008727
1 37451 2981496542
0 94248 2981496542
1 71333 42228574
0 7...

output:

1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62...

result:

ok 49999 lines

Test #7:

score: 0
Accepted
time: 6370ms
memory: 1381084kb

input:

100000 100000
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1 30030 4294967295
1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
99800 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2...

result:

ok 162 lines