QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#882171#4892. 序列SapnapTT20 963ms4992kbC++20905b2025-02-04 21:37:262025-02-04 21:37:26

Judging History

This is the latest submission verdict.

  • [2025-02-04 21:37:26]
  • Judged
  • Verdict: 20
  • Time: 963ms
  • Memory: 4992kb
  • [2025-02-04 21:37:26]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m;
struct node{
	int i[3],x;
}q[N];
int a[N];
mt19937 rnd(time(0));
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		a[i]=1;
	}
	for(int i=1;i<=m;i++){
		cin>>q[i].i[0]>>q[i].i[1]>>q[i].i[2]>>q[i].x;
		shuffle(q[i].i,q[i].i+3,rnd);
		a[q[i].i[0]]=q[i].x;
	}
	double s=clock();
	while((clock()-s)/CLOCKS_PER_SEC<0.95){
		bool flag=1;
		for(int i=1;i<=m;i++){
			if(a[q[i].i[0]]+a[q[i].i[1]]+a[q[i].i[2]]-max(a[q[i].i[0]],max(a[q[i].i[1]],a[q[i].i[2]]))-min(a[q[i].i[0]],min(a[q[i].i[1]],a[q[i].i[2]]))!=q[i].x){
				shuffle(q[i].i,q[i].i+3,rnd);
				a[q[i].i[0]]=q[i].x;
				flag=0;
//				break;
			}
		}
		if(flag){
			cout<<"YES\n";
			for(int i=1;i<=n;i++){
				cout<<a[i]<<' ';
			}
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 1ms
memory: 3712kb

input:

10 10
6 3 10 133562624
8 7 6 685486592
4 2 7 332482851
10 8 9 211550017
2 10 1 165556251
10 8 5 211550017
6 8 2 332482851
4 9 2 332482851
8 1 4 193658790
9 6 10 728674154

output:

YES
165556251 332482851 133562624 193658790 211550017 728674154 685486592 211550017 728674154 133562624 

result:

ok solution is correct

Test #2:

score: 20
Accepted
time: 0ms
memory: 3712kb

input:

10 9
5 3 7 489042696
10 9 3 489042696
5 9 4 589265757
1 3 7 489042696
9 3 10 489042696
2 8 7 402617168
2 4 5 564742148
1 8 3 615037121
2 8 4 564742148

output:

YES
615037121 402617168 489042696 564742148 589265757 1 402617168 615037121 589265757 1 

result:

ok solution is correct

Test #3:

score: 20
Accepted
time: 1ms
memory: 3584kb

input:

9 9
3 8 4 385329352
1 4 5 826490084
4 5 9 866319564
2 4 1 449825973
8 3 5 385329352
6 2 9 88759441
3 6 9 88759441
6 8 9 385329352
4 8 1 449825973

output:

YES
826490084 88759441 88759441 449825973 866319564 88759441 1 385329352 866319564 

result:

ok solution is correct

Test #4:

score: 20
Accepted
time: 685ms
memory: 3712kb

input:

10 10
1 9 6 957652738
9 7 1 934947905
9 10 8 507132050
5 2 8 162855738
2 2 8 537894544
9 9 9 266667281
3 3 8 158325440
2 7 9 752321309
10 3 1 104743493
4 10 10 799817379

output:

NO

result:

ok no solution

Test #5:

score: 20
Accepted
time: 655ms
memory: 3712kb

input:

8 9
7 4 7 187362209
5 1 1 634248682
2 3 2 664513540
3 2 4 161388361
5 1 3 463648080
8 1 6 485087787
6 3 6 689280466
3 6 8 116609606
7 2 7 399054929

output:

NO

result:

ok no solution

Test #6:

score: 20
Accepted
time: 1ms
memory: 3712kb

input:

10 8
5 6 10 861588864
10 1 8 608002433
8 3 4 196795234
1 8 3 285047219
9 7 5 480962478
6 10 1 780552157
3 4 2 190713929
7 5 6 780552157

output:

YES
608002433 1 190713929 196795234 861588864 780552157 480962478 285047219 1 861588864 

result:

ok solution is correct

Test #7:

score: 20
Accepted
time: 0ms
memory: 3712kb

input:

10 5
6 5 1 644007358
4 2 1 644007358
8 5 1 672067709
7 2 1 845787134
9 8 5 672067709

output:

YES
644007358 845787134 1 644007358 672067709 1 845787134 672067709 1 1 

result:

ok solution is correct

Test #8:

score: 20
Accepted
time: 0ms
memory: 3712kb

input:

9 6
9 6 3 408886589
3 2 1 680261634
8 4 1 540611446
6 3 2 680261634
5 2 1 540611446
7 3 2 680261634

output:

YES
1 680261634 680261634 540611446 540611446 408886589 680261634 540611446 1 

result:

ok solution is correct

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 10
Accepted
time: 73ms
memory: 3968kb

input:

40 9880
4 19 31 610502845
10 19 33 190412843
21 24 39 649028784
16 22 40 569593239
5 9 37 550862419
11 23 40 654613112
6 18 23 492267246
22 23 30 538715841
6 16 24 407919735
5 16 18 388907784
2 16 18 388907784
21 24 28 281403057
7 12 27 451830401
3 11 16 508407438
15 33 36 561955959
6 23 29 70605893...

output:

YES
877488996 197498120 508407438 610502845 209356929 706058934 655952999 624132238 550862419 32695410 654613112 72694954 399757770 396827347 561955959 407919735 779328631 388907784 190412843 657895429 832003778 569593239 492267246 32695410 718125822 812463588 451830401 281403057 877488996 538715841...

result:

ok solution is correct

Test #10:

score: 0
Wrong Answer
time: 963ms
memory: 4992kb

input:

80 82160
8 15 41 111467584
35 54 58 471689837
51 66 69 545620573
20 63 76 46182451
15 34 40 54922534
19 27 49 410013534
6 13 18 849916477
3 12 30 436881726
8 23 54 239683045
6 37 40 544597112
29 52 70 792746131
7 52 75 478735558
11 50 74 735803963
4 28 50 415323204
23 54 68 347125331
33 67 70 525526...

output:

NO

result:

wrong answer verdict is not correct

Subtask #3:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #16:

score: 0
Wrong Answer
time: 943ms
memory: 3840kb

input:

1000 996
527 924 774 540173899
415 382 71 188751360
884 463 698 125924043
810 890 663 324838547
366 94 515 666179824
192 778 279 847431254
769 80 245 922736826
529 115 418 778769842
446 715 604 875242794
160 625 423 424822525
877 194 974 556338768
198 70 696 237534851
8 304 726 470021479
496 953 866...

output:

NO

result:

wrong answer verdict is not correct

Subtask #4:

score: 0
Skipped

Dependency #2:

0%