QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#883301 | #10043. Mod Graph | lgvc# | WA | 1ms | 3840kb | C++23 | 1.8kb | 2025-02-05 15:43:37 | 2025-02-05 15:43:38 |
Judging History
answer
#include <bits/stdc++.h>
//v01
//v10
//v00
//vv
int N,M,Q,a[50009],b[50009],c[50009],hd[50009],to[200009],nxt[200009],k,ff,
qw,sa,sb;
void ad(int x,int y) {
if(c[x]==0) sa=(sa+y)%qw;
else sb=(sb+y)%qw;
}
void tr(int x,int y) {
c[x]=y;
for(int i=hd[x];i;i=nxt[i]) {
if(c[to[i]]==-1) {
tr(to[i],1^y);
} else {
if(c[to[i]]==y) ff=1;
}
}
}
void l(int u,int v) {
to[++k]=v;nxt[k]=hd[u];hd[u]=k;
}
signed main(void) {
scanf("%d %d %d",&N,&M,&Q);
for(int i=1;i<=N;i++) {
scanf("%d",&a[i]);
}
for(int i=1;i<=N;i++) {
scanf("%d",&b[i]);
qw=std::__gcd(qw,b[i]);
c[i]=-1;
}
for(int i=1;i<=M;i++) {
int x,y;
scanf("%d %d",&x,&y);
l(x,y),l(y,x);
}
for(int i=1;i<=N;i++) {
if(c[i]==-1) tr(i,0);
}
for(int i=1;i<=N;i++) {
ad(i,a[i]);
}
// printf("!\n");
while(Q--) {
int op;
scanf("%d",&op);
if(op==2) {
int x,v;
scanf("%d %d",&x,&v);
ad(x,(v-a[x]+b[x])%b[x]);
a[x]=v;
} else {
if(ff) {
printf("YES\n");
continue;
}
int x;
scanf("%d",&x);
int q=c[x];
if(q==1) {
if(sa==sb||sa==(sb+1)%qw) {
printf("YES\n");
} else {
printf("NO\n");
}
} else {
if(sa==sb||sb==(sa+1)%qw) {
printf("YES\n");
} else {
printf("NO\n");
}
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
input:
2 1 4 0 0 3 3 1 2 1 1 2 1 1 1 1 1 2
output:
YES NO YES
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
100 99 20 545176231 2149009 296810352 464294904 517017443 161996875 277531414 227239364 669511769 802762188 72982507 53014228 151954698 803486 7450102 102035596 224137078 59092001 429939358 61593212 125109334 755529743 101606658 282438874 178852420 24856971 174481974 68000852 7807479 203105121 50530...
output:
NO NO YES YES YES NO YES YES
result:
ok 8 token(s): yes count is 5, no count is 3
Test #3:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
100 99 20 336342577 39468089 363971406 252846803 475758534 371077308 44779697 114283328 387639202 176490048 691797700 218742599 55250669 101677476 710976901 290175579 125954990 590690266 295640500 559569481 777772175 91729825 25367669 347238826 97265071 166456655 215699647 252678796 555339722 818759...
output:
YES YES YES YES YES YES YES YES YES YES
result:
ok 10 token(s): yes count is 10, no count is 0
Test #4:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
100 200 20 376217719 40752341 199958286 733157884 165613590 122258495 16842149 138379722 469440397 205674823 344950589 24835950 7044922 197758921 535437376 2540953 112119947 223063142 44967578 221181144 585079167 393892026 728588471 5881809 193202233 359753346 652786358 282317378 331284029 619260995...
output:
YES NO YES YES YES YES NO YES YES YES
result:
ok 10 token(s): yes count is 8, no count is 2
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3840kb
input:
100 200 20 370875071 154466455 758306944 64495650 533714565 300239278 99080590 362329958 79378734 103274217 205250835 511582589 345401636 168791237 62615996 282196842 175048464 166208163 421127710 1239481 356604786 202328347 62889425 543321761 399597138 126307432 510390488 29685754 15005612 15951477...
output:
YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES
result:
wrong answer Output contains longer sequence [length = 16], but answer contains 11 elements