QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#502575 | #8711. Tiles | Scapegoat_Dawn | 0 | 122ms | 180972kb | C++17 | 3.1kb | 2024-08-03 09:49:54 | 2024-08-03 09:50:04 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define int long long
//#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 400005
#define inf 0x3f3f3f3f
int n,m;
int x[maxn],y[maxn],t[maxn],tx[maxn],lx;
vector<pii>buc[maxn];
struct info{
int l,r;
bool f[2][2];
info(){
l=r=-1;
memset(f,0,sizeof f);
}
};
//
info gen(int l,int r,int y){
info t;
if(!y){
For(i,0,1) t.f[i][i]=1;
t.l=-1;
t.r=-1;
}else{
t.l=l,t.r=r;
For(i,0,1) For(j,0,1) t.f[i][j]=((i==j)==((r-l+1)%2==0));
}
return t;
}
info merge(info a,info b){
if(a.l==-1) return b;
if(b.l==-1) return a;
info c;
c.l=a.l,c.r=b.r;
For(x,0,1)
For(y,0,1) if(a.f[x][y] && (!y||a.r+1==b.l))
For(z,0,1)
if(b.f[y][z]) c.f[x][z]=1;
return c;
}
struct segt{
info tr[maxn<<2][2];
bool rev[maxn<<2];
void up(int p){
For(i,0,1) tr[p][i]=merge(tr[p<<1][i],tr[p<<1|1][i]);
}
void pt(int p){
rev[p]^=1;
swap(tr[p][0],tr[p][1]);
}
void down(int p){
if(rev[p]){
pt(p<<1),pt(p<<1|1);
rev[p]=0;
}
}
void mdf(int p,int l,int r,int ql,int qr){
if(l>=ql&&r<=qr)return pt(p);
int mid=l+r>>1; down(p);
if(ql<=mid) mdf(p<<1,l,mid,ql,qr);
if(qr>mid) mdf(p<<1|1,mid+1,r,ql,qr);
up(p);
}
void build(int p,int l,int r){
// cout<<"build "<<p<<" "<<l<<" "<<r<<"\n";
if(l==r){
For(i,0,1) tr[p][i]=gen(t[l],t[l+1]-1,i);
return;
}
int mid=l+r>>1;
build(p<<1,l,mid);
build(p<<1|1,mid+1,r);
up(p);
}
bool chk(){
return tr[1][0].f[0][0];
}
bool chk0(){
return tr[1][0].l==-1;
}
}T[2];
signed main()
{
n=read(),m=read(); int mm=m; m=0;
For(i,1,n)x[i]=read(),y[i]=read(),t[++m]=y[i],tx[++lx]=x[i];
sort(t+1,t+m+1); sort(tx+1,tx+lx+1);
m=unique(t+1,t+m+1)-t-1,lx=unique(tx+1,tx+lx+1)-tx-1;
For(i,1,n){
x[i]=lower_bound(tx+1,tx+lx+1,x[i])-tx;
y[i]=lower_bound(t+1,t+m+1,y[i])-t;
}
For(i,1,n){
int j=i%n+1;
if(x[i]==x[j]) buc[x[i]].pb(mkp(min(y[i],y[j]),max(y[i],y[j])));
}
//cout<<"---\n";
T[0].build(1,1,m-1);
T[1]=T[0];
int o=0;
int res=tx[1];
tx[lx+1]=2e9;
For(i,1,lx){
// cout<<"i: "<<i<<"\n";
for(auto [l,r]:buc[i]) T[o].mdf(1,1,m-1,l,r-1);
if(T[o].chk0()) res=max(res,tx[i]);
int tt[2]={tx[i+1],tx[i+1]-1};
if((tt[0]-tx[i])%2) swap(tt[0],tt[1]);
if((tx[i+1]-tx[i])>=2){
if(!T[!o].chk()){
cout<<res;
exit(0);
}
}
if(T[o].chk0() && tt[1]>=tx[i]) res=max(res,tt[1]);
if(T[!o].chk0() && tt[0]>=tx[i]) res=max(res,tt[0]);
if((tx[i+1]-tx[i])%2){
o^=1;
}
}
res=min(res,mm);
cout<<res;
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 172868kb
input:
4 3 0 0 0 3 3 3 3 0
output:
2
result:
wrong answer 1st lines differ - expected: '0', found: '2'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #32:
score: 11
Accepted
time: 7ms
memory: 173216kb
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: 0
Wrong Answer
time: 31ms
memory: 173292kb
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:
15163970
result:
wrong answer 1st lines differ - expected: '14903120', found: '15163970'
Subtask #4:
score: 0
Wrong Answer
Test #45:
score: 19
Accepted
time: 25ms
memory: 172840kb
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
Accepted
time: 11ms
memory: 173800kb
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:
6
result:
ok single line: '6'
Test #47:
score: 19
Accepted
time: 56ms
memory: 179980kb
input:
199996 966 752 702 754 702 754 700 756 700 756 702 758 702 758 700 760 700 760 702 762 702 762 700 764 700 764 702 766 702 766 700 768 700 768 702 770 702 770 700 772 700 772 702 774 702 774 700 776 700 776 702 778 702 778 700 780 700 780 702 782 702 782 700 784 700 784 702 786 702 786 700 788 700 7...
output:
0
result:
ok single line: '0'
Test #48:
score: 19
Accepted
time: 48ms
memory: 179180kb
input:
199996 966 748 702 750 702 750 700 752 700 752 702 754 702 754 700 756 700 756 702 758 702 758 700 760 700 760 702 762 702 762 700 764 700 764 702 766 702 766 700 768 700 768 702 770 702 770 700 772 700 772 702 774 702 774 700 776 700 776 702 778 702 778 700 780 700 780 702 782 702 782 700 784 700 7...
output:
962
result:
ok single line: '962'
Test #49:
score: 19
Accepted
time: 19ms
memory: 173008kb
input:
500 916 560 975 560 526 544 526 544 708 538 708 538 585 534 585 534 879 530 879 530 612 514 612 514 907 512 907 512 571 504 571 504 976 494 976 494 746 486 746 486 922 478 922 478 667 476 667 476 913 472 913 472 623 456 623 456 890 450 890 450 609 446 609 446 905 436 905 436 705 428 705 428 816 418 ...
output:
900
result:
ok single line: '900'
Test #50:
score: 19
Accepted
time: 8ms
memory: 172536kb
input:
500 980 421 481 453 481 453 479 32 479 32 477 453 477 453 461 353 461 353 451 403 451 403 441 176 441 176 435 314 435 314 429 128 429 128 417 129 417 129 413 31 413 31 401 136 401 136 399 130 399 130 398 130 391 217 391 217 383 6 383 6 369 105 369 105 365 84 365 84 353 178 353 178 345 0 345 0 343 26...
output:
0
result:
ok single line: '0'
Test #51:
score: 19
Accepted
time: 20ms
memory: 172588kb
input:
8480 1000 410 61 410 63 410 69 410 70 410 71 410 83 410 87 410 88 410 89 410 90 410 91 410 93 410 95 410 97 410 106 410 108 410 109 410 117 410 118 410 121 410 123 410 126 410 129 410 133 410 134 410 139 410 140 410 143 410 145 410 149 410 150 410 152 410 154 410 157 410 158 410 159 410 162 410 164 ...
output:
1000
result:
ok single line: '1000'
Test #52:
score: 19
Accepted
time: 19ms
memory: 172616kb
input:
500 976 590 415 590 63 604 63 604 439 612 439 612 262 614 262 614 284 624 284 624 31 636 31 636 65 646 65 646 28 648 28 648 341 656 341 656 241 666 241 666 421 670 421 670 147 684 147 684 326 688 326 688 3 696 3 696 254 708 254 708 39 712 39 712 322 726 322 726 293 728 293 728 447 740 447 740 57 748...
output:
972
result:
ok single line: '972'
Test #53:
score: 19
Accepted
time: 11ms
memory: 174304kb
input:
502 993 993 0 991 0 991 4 989 4 989 8 987 8 987 12 985 12 985 16 983 16 983 20 981 20 981 24 979 24 979 28 977 28 977 32 975 32 975 36 973 36 973 40 971 40 971 44 969 44 969 48 967 48 967 52 965 52 965 56 963 56 963 60 961 60 961 64 959 64 959 68 957 68 957 72 955 72 955 76 953 76 953 80 951 80 951 ...
output:
494
result:
ok single line: '494'
Test #54:
score: 19
Accepted
time: 17ms
memory: 173884kb
input:
500 990 261 369 383 369 383 365 45 365 45 363 341 363 341 343 78 343 78 341 78 339 105 339 105 325 19 325 19 321 113 321 113 313 74 313 74 309 272 309 272 301 3 301 3 299 191 299 191 285 103 285 103 273 460 273 460 265 153 265 153 257 278 257 278 253 129 253 129 243 283 243 283 239 11 239 11 233 254...
output:
982
result:
ok single line: '982'
Test #55:
score: 0
Wrong Answer
time: 32ms
memory: 175476kb
input:
1213 996 960 224 960 225 960 229 960 230 960 233 960 234 960 235 960 236 960 237 960 238 960 240 960 242 960 243 960 244 960 245 960 246 960 248 960 249 960 250 960 251 960 252 960 253 960 254 960 255 960 256 960 259 960 260 960 264 960 266 961 266 962 266 962 269 962 271 962 272 962 273 962 274 962...
output:
27
result:
wrong answer 1st lines differ - expected: '0', found: '27'
Subtask #5:
score: 0
Wrong Answer
Test #89:
score: 22
Accepted
time: 79ms
memory: 179768kb
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: 22
Accepted
time: 59ms
memory: 179324kb
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: 22
Accepted
time: 63ms
memory: 178956kb
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: 22
Accepted
time: 67ms
memory: 179596kb
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
Accepted
time: 81ms
memory: 180244kb
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:
13366
result:
ok single line: '13366'
Test #94:
score: 22
Accepted
time: 78ms
memory: 180328kb
input:
200000 1000000000 684694139 795608956 684694139 795624096 684697059 795624096 684697059 795626100 684706431 795626100 684706431 795627636 684723897 795627636 684723897 795629488 684739661 795629488 684739661 795629884 684747463 795629884 684747463 795637960 684749717 795637960 684749717 795650464 68...
output:
33676
result:
ok single line: '33676'
Test #95:
score: 22
Accepted
time: 122ms
memory: 180784kb
input:
200000 1000000000 46181104 58318020 46181104 58296528 46177454 58296528 46177454 58295540 46175192 58295540 46175192 58283280 46160546 58283280 46160546 58257456 46152376 58257456 46152376 58240260 46149232 58240260 46149232 58234984 46135618 58234984 46135618 58228216 46117434 58228216 46117434 582...
output:
257649284
result:
ok single line: '257649284'
Test #96:
score: 0
Wrong Answer
time: 58ms
memory: 180308kb
input:
199996 554773273 457247489 96654740 457247489 98035522 457386217 98035522 457386217 99416304 457247489 99416304 457247489 100797086 457386217 100797086 457386217 102177868 457247489 102177868 457247489 103558650 457386217 103558650 457386217 104939432 457247489 104939432 457247489 106320214 45738621...
output:
497478608
result:
wrong answer 1st lines differ - expected: '392045328', found: '497478608'
Subtask #6:
score: 0
Wrong Answer
Test #118:
score: 0
Wrong Answer
time: 75ms
memory: 180972kb
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:
1000000000
result:
wrong answer 1st lines differ - expected: '40502', found: '1000000000'
Subtask #7:
score: 0
Skipped
Dependency #1:
0%