QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#423781 | #8708. Portal | Matutino | 1 | 39ms | 5228kb | C++14 | 1.0kb | 2024-05-28 16:27:49 | 2024-05-28 16:27:50 |
Judging History
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=410,V=200;
int n,fa[N*N],ID[N][N],idx;
struct Node{int x,y;}p[N];
int find(reg int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
inline void merge(reg int x,reg int y){
x=find(x),y=find(y);
if (x!=y) fa[x]=y;
}
signed main(){
n=read();
for (reg int i=1;i<=n;i++) p[i].x=read(),p[i].y=read();
for (reg int i=-V;i<=V;i++) for (reg int j=-V;j<=V;j++) ID[i+V][j+V]=++idx;
for (reg int i=1;i<=idx;i++) fa[i]=i;
for (reg int x=-V;x<=V;x++) for (reg int y=-V;y<=V;y++){
reg int now=0;
for (reg int i=1;i<=n;i++){
reg int X=x+p[i].x,Y=y+p[i].y;
if (X<-V||X>V||Y<-V||Y>V) break;
reg int nw=ID[X+V][Y+V];
if (!now) now=nw; else merge(now,nw);
}
}
reg int ans=0;
for (reg int i=1;i<=idx;i++) ans+=find(i)==i;
printf("%d\n",ans==idx?-1:ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 1ms
memory: 5116kb
input:
1 1 -1
output:
-1
result:
ok single line: '-1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5108kb
input:
2 -455833 -283524 427847 159281
output:
-1
result:
ok single line: '-1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5224kb
input:
2 52420 -46322 -192914 87067
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5108kb
input:
2 52446 -20773 179773 174566
output:
-1
result:
ok single line: '-1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 5116kb
input:
2 -229012 -260770 -174790 -69382
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5084kb
input:
2 -127294 418312 211124 37002
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 1ms
memory: 5112kb
input:
2 -129173 516840 46821 -187136
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 1ms
memory: 5108kb
input:
2 -90088 -7423 234488 19625
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 1ms
memory: 5228kb
input:
2 -48105 256695 15135 -80585
output:
-1
result:
ok single line: '-1'
Test #10:
score: 0
Accepted
time: 1ms
memory: 5032kb
input:
2 -251318 79061 182792 -129183
output:
-1
result:
ok single line: '-1'
Test #11:
score: 0
Accepted
time: 0ms
memory: 5096kb
input:
2 784850 417677 -217245 -460999
output:
-1
result:
ok single line: '-1'
Test #12:
score: 0
Accepted
time: 1ms
memory: 5116kb
input:
2 31270 410692 713271 917276
output:
-1
result:
ok single line: '-1'
Test #13:
score: 0
Accepted
time: 1ms
memory: 5056kb
input:
1 230862 -785444
output:
-1
result:
ok single line: '-1'
Test #14:
score: 0
Accepted
time: 1ms
memory: 5112kb
input:
2 222814 -279784 -73657 59849
output:
-1
result:
ok single line: '-1'
Test #15:
score: 0
Accepted
time: 0ms
memory: 5120kb
input:
2 72171 -104186 201480 105502
output:
-1
result:
ok single line: '-1'
Test #16:
score: 0
Accepted
time: 0ms
memory: 5104kb
input:
2 -17727 -27151 69235 15029
output:
-1
result:
ok single line: '-1'
Test #17:
score: 0
Accepted
time: 1ms
memory: 5104kb
input:
2 -44049 96618 173806 -21489
output:
-1
result:
ok single line: '-1'
Test #18:
score: 0
Accepted
time: 1ms
memory: 5060kb
input:
2 -81268 -53452 329866 -163275
output:
-1
result:
ok single line: '-1'
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #19:
score: 0
Wrong Answer
time: 4ms
memory: 5108kb
input:
3 1 1 1 3 3 2
output:
805
result:
wrong answer 1st lines differ - expected: '4', found: '805'
Subtask #3:
score: 0
Runtime Error
Test #40:
score: 0
Runtime Error
input:
99840 -359536 735499 -710626 400619 -468266 -282389 -192706 43659 204034 -543669 -100576 -749013 -118006 -283125 -341276 405771 560934 835595 -923936 506603 239724 956299 -680746 -737237 286204 982795 -847576 -282389 -949666 986475 996684 -429589 672984 -133717 140954 696491 -879116 -442837 985064 7...
output:
result:
Subtask #4:
score: 0
Wrong Answer
Test #59:
score: 29
Accepted
time: 6ms
memory: 5116kb
input:
5 0 0 1 0 -1 0 0 1 0 -1
output:
1
result:
ok single line: '1'
Test #60:
score: -29
Wrong Answer
time: 39ms
memory: 5160kb
input:
100 -30 -13 -22 -19 32 9 -18 -11 50 19 16 5 -50 -17 -46 -21 10 -1 -56 -19 2 -11 -24 -15 -4 -11 -8 -11 4 7 -8 -5 34 9 18 7 20 1 -12 -11 -30 -23 -42 -13 -24 -3 16 11 -16 -7 -24 -21 2 -9 28 11 6 -9 -22 -11 4 -7 28 7 -36 -15 -20 -21 4 11 -8 5 20 5 30 21 58 19 4 -1 -46 -19 -6 3 2 11 46 15 18 -1 -24 -7 -2...
output:
1416
result:
wrong answer 1st lines differ - expected: '4', found: '1416'
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%