QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#424523#8711. TilesMatutino#0 43ms25944kbC++141.6kb2024-05-29 12:00:332024-05-29 12:00:34

Judging History

This is the latest submission verdict.

  • [2024-05-29 12:00:34]
  • Judged
  • Verdict: 0
  • Time: 43ms
  • Memory: 25944kb
  • [2024-05-29 12:00:33]
  • Submitted

answer

#include<bits/stdc++.h>
// #define int long long
#define reg register
inline int read(){
	int k=1,x=0;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') k=-1; ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-48,ch=getchar();
	return k*x;
}
const int N=5e5+10,INF=1e18;
int n,m,mx,my,bx[N],by[N],ans;
struct Node{int x,y;}p[N];
std::vector<std::pair<int,int>> vc[N];
int vis[N];
signed main(){
	n=read(),m=read();
	for (reg int i=1;i<=n;i++) bx[++mx]=p[i].x=read(),by[++my]=p[i].y=read(); 
	std::sort(bx+1,bx+mx+1),std::sort(by+1,by+my+1);
	mx=std::unique(bx+1,bx+mx+1)-bx-1,my=std::unique(by+1,by+my+1)-by-1;
	for (reg int i=1;i<=n;i++){
		p[i].x=std::lower_bound(bx+1,bx+mx+1,p[i].x)-bx;
		p[i].y=std::lower_bound(by+1,by+my+1,p[i].y)-by;
	}
	// for (reg int i=1;i<=n;i++) std::cerr<<"node "<<p[i].x<<" "<<p[i].y<<"\n";
	p[n+1]=p[1];
	for (reg int i=1;i<=n;i++) if (p[i].x==p[i+1].x)
		vc[p[i].x].push_back({std::min(p[i].y,p[i+1].y),std::max(p[i].y,p[i+1].y)});
	for (reg int i=1;i<=mx;i++){ 
		reg int flg=0;
		for (auto [l,r]:vc[i]){
			reg int lst=0;
			for (reg int j=l+1;j<=r;j++){
				if (vis[j]>-1){
					if (bx[i]-vis[j]&1){flg=1;break;} 
					vis[j]=-1;
				}else{
					if ((by[j]-by[j-1]&1)!=lst){
						if (vis[j+1]!=-1&&(vis[j+1]-bx[i]&1)){flg=1;break;}
					}
					lst^=by[j]-by[j-1]&1;
					vis[j]=bx[i];
				}
			}
		}
		if (flg) break; reg int op=-1;
		for (reg int j=2;j<=my;j++) if (vis[j]>-1){
			reg int d=bx[i]-vis[j]&1;
			if (op==-1) op=d; else if (op!=d){flg=1;break;}
		}
		if (!flg&&op!=-1) ans=bx[i]-op,std::cerr<<"ans "<<bx[i]-op<<"\n";
	}
	printf("%d\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

4 3
0 0
0 3
3 3
3 0

output:

0

result:

ok single line: '0'

Test #2:

score: -4
Wrong Answer
time: 0ms
memory: 20288kb

input:

4 999999999
999999999 0
999999999 1000000000
0 1000000000
0 0

output:

999999999

result:

wrong answer 1st lines differ - expected: '999999998', found: '999999999'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #32:

score: 11
Accepted
time: 2ms
memory: 20204kb

input:

1551 1000
0 988
2 988
3 988
6 988
6 985
6 982
6 981
6 979
6 978
6 977
6 976
6 975
6 974
6 972
6 970
6 969
6 968
6 966
6 965
6 964
7 964
8 964
8 963
8 961
8 960
10 960
11 960
13 960
16 960
16 959
16 958
16 957
16 954
16 953
16 951
16 950
17 950
18 950
18 948
18 946
18 945
18 944
18 942
18 941
18 939
...

output:

164

result:

ok single line: '164'

Test #33:

score: -11
Wrong Answer
time: 6ms
memory: 22904kb

input:

36221 1000000000
0 996776952
43916 996776952
43916 996301596
102050 996301596
102050 995243908
173144 995243908
173144 992639626
184542 992639626
184542 987461238
192474 987461238
192474 982703402
406098 982703402
406098 980100986
525272 980100986
525272 978443232
532708 978443232
532708 977775310
6...

output:

15015446

result:

wrong answer 1st lines differ - expected: '14903120', found: '15015446'

Subtask #4:

score: 0
Wrong Answer

Test #45:

score: 19
Accepted
time: 4ms
memory: 20172kb

input:

14 6
0 1
0 3
2 3
2 4
0 4
0 6
3 6
3 7
4 7
6 7
6 5
3 5
3 2
3 1

output:

2

result:

ok single line: '2'

Test #46:

score: -19
Wrong Answer
time: 0ms
memory: 22240kb

input:

18 9
0 2
2 2
2 1
4 1
4 0
9 0
9 2
4 2
4 4
7 4
7 3
9 3
9 6
4 6
4 5
2 5
2 4
0 4

output:

4

result:

wrong answer 1st lines differ - expected: '6', found: '4'

Subtask #5:

score: 0
Wrong Answer

Test #89:

score: 22
Accepted
time: 28ms
memory: 24924kb

input:

199996 198506138
31225688 248200160
31225688 248291950
28995282 248291950
28995282 248200160
26764876 248200160
26764876 248291950
24534470 248291950
24534470 248200160
22304064 248200160
22304064 248291950
20073658 248291950
20073658 248200160
17843252 248200160
17843252 248291950
15612846 24829195...

output:

0

result:

ok single line: '0'

Test #90:

score: 0
Accepted
time: 24ms
memory: 23532kb

input:

199996 740789144
48843244 341844840
48843244 342042210
40702704 342042210
40702704 341844840
32562164 341844840
32562164 342042210
24421624 342042210
24421624 341844840
16281084 341844840
16281084 342042210
8140544 342042210
8140544 341450100
16281084 341450100
16281084 341647470
24421624 341647470
...

output:

0

result:

ok single line: '0'

Test #91:

score: 0
Accepted
time: 24ms
memory: 24924kb

input:

199996 198506138
31225684 248200166
31225684 248291956
28995278 248291956
28995278 248200166
26764872 248200166
26764872 248291956
24534466 248291956
24534466 248200166
22304060 248200166
22304060 248291956
20073654 248291956
20073654 248200166
17843248 248200166
17843248 248291956
15612842 24829195...

output:

198506134

result:

ok single line: '198506134'

Test #92:

score: 0
Accepted
time: 25ms
memory: 23024kb

input:

199996 740789144
48843240 341844840
48843240 342042210
40702700 342042210
40702700 341844840
32562160 341844840
32562160 342042210
24421620 342042210
24421620 341844840
16281080 341844840
16281080 342042210
8140540 342042210
8140540 341450100
16281080 341450100
16281080 341647470
24421620 341647470
...

output:

740789140

result:

ok single line: '740789140'

Test #93:

score: -22
Wrong Answer
time: 43ms
memory: 25944kb

input:

199999 1000000000
1000000000 0
999999222 0
999999222 136
999984018 136
999984018 228
999973482 228
999973482 292
999971160 292
999971160 396
999964886 396
999964886 588
999959042 588
999959042 680
999955190 680
999955190 732
999927188 732
999927188 748
999913912 748
999913912 796
999912122 796
99991...

output:

4926

result:

wrong answer 1st lines differ - expected: '13366', found: '4926'

Subtask #6:

score: 0
Time Limit Exceeded

Test #118:

score: 0
Time Limit Exceeded

input:

200000 1000000000
1000000000 0
999990876 0
999990876 38
999972524 38
999972524 1510
999969180 1510
999969180 3734
999964780 3734
999964780 4138
999960464 4138
999960464 11052
999953728 11052
999953728 24478
999914972 24478
999914972 25892
999909864 25892
999909864 28102
999902920 28102
999902920 301...

output:


result:


Subtask #7:

score: 0
Skipped

Dependency #1:

0%