QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#500237#437. Fun TourRafi22100 ✓82ms21020kbC++202.8kb2024-08-01 04:11:512024-08-01 04:11:51

Judging History

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

  • [2024-08-01 04:11:51]
  • 评测
  • 测评结果:100
  • 用时:82ms
  • 内存:21020kb
  • [2024-08-01 04:11:51]
  • 提交

answer

    #include "fun.h"
    #include <bits/stdc++.h>
    using namespace std;
     
    #ifdef DEBUG
    auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
    auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
    #define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
    #else
    #define debug(...){}
    #endif
     
    #define ll long long
    #define ld long double
    #define endl '\n'
    #define st first
    #define nd second
    #define pb push_back
    #define sz(x) (int)(x).size()
    #define all(x) (x).begin(), (x).end()
    #define FOR(i,l,r) for(int i=(l);i<=(r);i++)
    #define ROF(i,r,l) for(int i=(r);i>=(l);i--)
    int inf=1000000007;
    ll infl=1000000000000000007;
    ll mod=1000000007;
     
    const int N=100007;
     
    int d[N];
    int s[N];
    int id[N];
    vector<pair<int,int>>X[3];
     
    vector<int>createFunTour(int n,int q)
    {
    	int C=-1,mn=inf;
    	FOR(i,0,n-1) 
    	{
    		s[i]=attractionsBehind(0,i);
    		if(s[i]>=(n+1)/2&&s[i]<mn)
    		{
    			mn=s[i];
    			C=i;
    		}
    	}
    	vector<pair<int,int>>V;
    	FOR(i,0,n-1)
    	{
    		d[i]=hoursRequired(C,i);
    		if(d[i]==1) 
    		{
    			if(s[i]>s[C]) V.pb({i,n-s[C]});
    			else V.pb({i,s[i]});
    		}
    	}
    	debug(C,V);
    	vector<int>ans;
    	FOR(i,0,n-1)
    	{
    		if(i==C) continue;
    		if(V[0].st==i||attractionsBehind(i,V[0].st)>=n-V[0].nd+1)id[i]=0;
    		else if(V[1].st==i||attractionsBehind(i,V[1].st)>=n-V[1].nd+1) id[i]=1;
    		else id[i]=2;
    		//debug(id[i],i);
    		X[id[i]].pb({d[i],i});
    	}
    	FOR(i,0,2) sort(all(X[i]));
    	int last=-1;
    	FOR(i,1,n-1)
    	{
    		int m=n-i;
    		int mx=-1,f=-1,xd=-1;
    		FOR(j,0,2)
    		{
    			if(j==last) continue;
    			if(sz(X[j])==(m+1)/2)
    			{
					bool nie=0;
					int D=0;
					FOR(l,0,2) if(l!=j&&sz(X[l])>0) D=max(D,X[l].back().st);
					if(sz(ans)>0&&d[ans.back()]<D) nie=1;
					if(!nie) xd=j;
				}
    			if(sz(X[j])>0&&X[j].back().st>mx)
    			{
    				mx=X[j].back().st;
    				f=j;
    			}
    		}
    		if(xd!=-1)
    		{
    			vector<pair<int,int>>A=X[xd],B;
    			FOR(j,0,2) if(j!=xd) for(auto p:X[j]) B.pb(p);
    			sort(all(A));
    			sort(all(B));
    			FOR(i,0,m-1) 
    			{
    				if(i%2==0)
    				{
    					ans.pb(A.back().nd);
    					A.pop_back();
    				}
    				else
    				{
    					ans.pb(B.back().nd);
    					B.pop_back();
    				}
    			}
    			break;
    		}
    		if(f==-1) exit(2137);
    		ans.pb(X[f].back().nd);
    		X[f].pop_back();
    		last=f;
    	}
    	ans.pb(C);
    	return ans;
    }

詳細信息

Subtask #1:

score: 0
Accepted

Test #1:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

2 400000
1 0

output:

0 1

result:

ok correct

Subtask #2:

score: 0
Accepted

Test #3:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

4 400000
1 0
2 0
3 1

output:

2 3 0 1

result:

ok correct

Subtask #3:

score: 0
Accepted

Test #9:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

4 400000
1 0
2 1
3 2

output:

0 3 1 2

result:

ok correct

Subtask #4:

score: 0
Accepted

Test #13:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

4 400000
0 1
0 2
0 3

output:

1 3 2 0

result:

ok correct

Subtask #5:

score: 0
Accepted

Test #20:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

18 400000
1 0
2 0
3 1
4 1
5 2
6 2
7 3
8 3
9 4
10 4
11 5
12 5
13 6
14 6
15 7
16 7
17 8

output:

14 17 13 16 12 15 11 8 6 7 5 10 2 9 3 4 0 1

result:

ok correct

Subtask #6:

score: 0
Accepted

Test #27:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

18 400000
7 6
8 7
5 8
4 5
3 4
9 3
10 11
12 10
13 12
14 13
9 14
2 9
15 2
16 15
17 16
1 17
0 1

output:

0 6 1 7 11 17 8 10 16 5 12 15 4 13 3 14 2 9

result:

ok correct

Subtask #7:

score: 0
Accepted

Test #33:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

500 400000
33 414
398 33
254 398
400 254
376 400
302 376
466 302
362 466
301 362
267 301
417 267
413 417
14 413
305 14
353 305
83 353
227 83
57 227
446 57
406 446
154 406
336 154
195 336
405 195
264 405
76 264
203 76
459 203
178 459
72 178
296 72
488 296
404 488
60 404
156 60
393 156
108 393
216 108...

output:

212 414 88 33 124 398 399 254 190 400 10 376 366 302 234 466 432 362 28 301 188 267 237 417 64 413 268 14 39 305 349 353 345 83 125 227 70 57 276 446 420 406 369 154 48 336 211 195 482 405 8 264 22 76 487 203 9 459 230 178 339 72 95 296 340 488 50 404 102 60 174 156 47 393 461 108 424 216 181 106 13...

result:

ok correct

Subtask #8:

score: 0
Accepted

Test #41:

score: 0
Accepted
time: 1ms
memory: 3936kb

input:

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

output:

500 318 499 317 498 316 497 315 496 314 495 313 494 312 493 311 492 310 491 309 490 308 489 307 488 306 487 305 486 304 485 303 484 302 483 301 482 300 481 299 480 298 479 297 478 296 477 295 476 294 475 293 474 292 473 291 472 290 471 289 470 288 469 287 468 286 467 285 466 284 465 283 464 282 463 ...

result:

ok correct

Subtask #9:

score: 0
Accepted

Test #51:

score: 0
Accepted
time: 0ms
memory: 4228kb

input:

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

output:

448 811 446 808 444 806 442 804 440 802 438 799 436 796 434 790 432 788 430 786 428 784 426 782 424 780 422 777 420 773 414 771 412 768 410 764 408 761 406 758 404 754 402 752 400 749 398 747 396 745 391 735 389 733 385 731 383 729 381 727 379 725 357 722 355 717 353 715 351 713 349 711 347 709 345 ...

result:

ok correct

Subtask #10:

score: 0
Accepted

Test #59:

score: 0
Accepted
time: 82ms
memory: 21020kb

input:

99999 400000
11681 58292
11681 63929
49752 11681
30596 74400
30596 39261
49752 30596
19390 49752
89694 31923
19390 89694
54297 19390
42389 12902
42389 60328
72803 42389
69881 43761
69881 95741
72803 69881
96271 72803
63872 20658
63872 93588
35833 63872
48418 44153
35833 48418
96271 35833
54297 96271...

output:

99984 99998 99976 99994 99975 99993 99972 99992 99971 99988 99966 99986 99962 99985 99960 99980 99956 99973 99955 99970 99951 99964 99943 99963 99942 99959 99934 99954 99932 99952 99928 99946 99927 99945 99925 99944 99922 99941 99921 99940 99920 99933 99918 99930 99915 99929 99914 99926 99912 99923 ...

result:

ok correct

Subtask #11:

score: 10
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Subtask #12:

score: 16
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Subtask #13:

score: 21
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #8:

100%
Accepted

Subtask #14:

score: 19
Accepted

Dependency #1:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #9:

100%
Accepted

Subtask #15:

score: 34
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Dependency #8:

100%
Accepted

Dependency #9:

100%
Accepted

Dependency #10:

100%
Accepted

Dependency #11:

100%
Accepted

Dependency #12:

100%
Accepted

Dependency #13:

100%
Accepted

Dependency #14:

100%
Accepted

Extra Test:

score: 0
Extra Test Passed