QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#842874 | #8708. Portal | zhassyn | 1 | 14ms | 5388kb | C++20 | 1.9kb | 2025-01-04 15:30:50 | 2025-01-04 15:30:59 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 1e5 + 100, M = 4096 + 10, len = 315, inf = 1e18;
const ll mod = 1e9 + 7;
ll um(ll a, ll b){
return (1LL * a * b) % mod;
}
ll subr(ll a, ll b){
return ((1LL * a - b) % mod + mod) % mod;
}
pll a[N];
ll n;
ll calc(ll x, ll b, ll c){
return abs(a[x].S - a[b].S) * abs(a[c].F - a[x].F);
}
ll cc(ll x, ll b, ll c){
return abs(a[x].F - a[b].F) * abs(a[c].S - a[x].S);
}
void subtask3(){
vector <ll> v1, v2;
for(ll i = 0; i < n; i++){
v1.pb(a[i].F);
}
for(ll i = 0; i < n; i++){
v2.pb(a[i].S);
}
sort(v1.begin(), v1.end());
sort(v2.begin(), v2.end());
ll a1 = 0, a2 = 0;
for(int i = 1; i < n; i++){
if(v1[i] != v1[i - 1]){
if(a1 == 0) a1 = v1[i] - v1[i - 1];
else a1 = __gcd(a1, v1[i] - v1[i - 1]);
}
if(v2[i] != v2[i - 1]){
if(a2 == 0) a2 = v2[i] - v2[i - 1];
else a2 = __gcd(a2, v2[i] - v2[i - 1]);
}
}
if(a1 == 0 || a2 == 0){
cout << -1;
} else{
cout << a1 * a2;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n;
bool s4 = true;
for(ll i = 0; i < n; i++){
cin >> a[i].F >> a[i].S;
}
if(n <= 2){
cout << -1;
return 0;
}
ll px = 0, py = 0, dy = 0;
for(ll i = 1; i < n; i++){
a[i].F -= a[0].F;
a[i].S -= a[0].S;
if(a[i].F < 0){
a[i].F *= -1;
a[i].S *= -1;
}
if(a[i].F){
px = a[i].F;
py = a[i].S;
}
}
if(px == 0){
cout << -1;
return 0;
}
for(ll i = 1; i < n; i++){
while(a[i].F){
ll k = px/a[i].F;
px -= k * a[i].F;
py -= k * a[i].S;
swap(a[i].F, px);
swap(a[i].S, py);
}
if(a[i].S) dy = __gcd(dy, abs(a[i].S));
}
if(py == 0) cout << -1;
else cout << abs(dy * px);
return 0;
}
詳細信息
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 0ms
memory: 3616kb
input:
1 1 -1
output:
-1
result:
ok single line: '-1'
Test #2:
score: 1
Accepted
time: 0ms
memory: 3756kb
input:
2 -455833 -283524 427847 159281
output:
-1
result:
ok single line: '-1'
Test #3:
score: 1
Accepted
time: 0ms
memory: 3800kb
input:
2 52420 -46322 -192914 87067
output:
-1
result:
ok single line: '-1'
Test #4:
score: 1
Accepted
time: 0ms
memory: 3612kb
input:
2 52446 -20773 179773 174566
output:
-1
result:
ok single line: '-1'
Test #5:
score: 1
Accepted
time: 0ms
memory: 3824kb
input:
2 -229012 -260770 -174790 -69382
output:
-1
result:
ok single line: '-1'
Test #6:
score: 1
Accepted
time: 0ms
memory: 3608kb
input:
2 -127294 418312 211124 37002
output:
-1
result:
ok single line: '-1'
Test #7:
score: 1
Accepted
time: 0ms
memory: 3552kb
input:
2 -129173 516840 46821 -187136
output:
-1
result:
ok single line: '-1'
Test #8:
score: 1
Accepted
time: 0ms
memory: 3552kb
input:
2 -90088 -7423 234488 19625
output:
-1
result:
ok single line: '-1'
Test #9:
score: 1
Accepted
time: 0ms
memory: 3544kb
input:
2 -48105 256695 15135 -80585
output:
-1
result:
ok single line: '-1'
Test #10:
score: 1
Accepted
time: 0ms
memory: 3612kb
input:
2 -251318 79061 182792 -129183
output:
-1
result:
ok single line: '-1'
Test #11:
score: 1
Accepted
time: 0ms
memory: 3656kb
input:
2 784850 417677 -217245 -460999
output:
-1
result:
ok single line: '-1'
Test #12:
score: 1
Accepted
time: 0ms
memory: 3796kb
input:
2 31270 410692 713271 917276
output:
-1
result:
ok single line: '-1'
Test #13:
score: 1
Accepted
time: 0ms
memory: 3500kb
input:
1 230862 -785444
output:
-1
result:
ok single line: '-1'
Test #14:
score: 1
Accepted
time: 0ms
memory: 3828kb
input:
2 222814 -279784 -73657 59849
output:
-1
result:
ok single line: '-1'
Test #15:
score: 1
Accepted
time: 0ms
memory: 3796kb
input:
2 72171 -104186 201480 105502
output:
-1
result:
ok single line: '-1'
Test #16:
score: 1
Accepted
time: 0ms
memory: 3548kb
input:
2 -17727 -27151 69235 15029
output:
-1
result:
ok single line: '-1'
Test #17:
score: 1
Accepted
time: 0ms
memory: 3548kb
input:
2 -44049 96618 173806 -21489
output:
-1
result:
ok single line: '-1'
Test #18:
score: 1
Accepted
time: 0ms
memory: 3832kb
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: 10
Accepted
time: 0ms
memory: 3752kb
input:
3 1 1 1 3 3 2
output:
4
result:
ok single line: '4'
Test #20:
score: 10
Accepted
time: 0ms
memory: 3548kb
input:
3 123741 -122828 207774 110184 -33847 97305
output:
55218331445
result:
ok single line: '55218331445'
Test #21:
score: 10
Accepted
time: 0ms
memory: 3552kb
input:
3 -66381 27989 200580 40286 300930 -238824
output:
75745488660
result:
ok single line: '75745488660'
Test #22:
score: 10
Accepted
time: 0ms
memory: 3560kb
input:
3 -212612 305891 -228367 216399 56731 149417
output:
26569291626
result:
ok single line: '26569291626'
Test #23:
score: 10
Accepted
time: 0ms
memory: 3548kb
input:
3 58252 388020 34720 -409605 79321 85296
output:
23928862293
result:
ok single line: '23928862293'
Test #24:
score: 10
Accepted
time: 0ms
memory: 3824kb
input:
3 19556 -29968 -52219 72940 153159 -166846
output:
3924399074
result:
ok single line: '3924399074'
Test #25:
score: 0
Wrong Answer
time: 0ms
memory: 3500kb
input:
3 201002 729262 -242878 -881858 183722 666542
output:
0
result:
wrong answer 1st lines differ - expected: '-1', found: '0'
Subtask #3:
score: 0
Wrong Answer
Test #40:
score: 10
Accepted
time: 10ms
memory: 5388kb
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:
610880
result:
ok single line: '610880'
Test #41:
score: 10
Accepted
time: 14ms
memory: 5360kb
input:
99680 231534 501002 -604126 79487 -337934 -601948 -869810 434312 -819518 524087 598310 79487 161938 -480538 463182 827612 233566 807092 -51422 666872 155334 -561763 -819518 -419833 290970 947312 -679818 -16273 804558 435167 -387210 223982 161938 223982 35954 373607 -854570 -459163 831482 771182 5251...
output:
434340
result:
ok single line: '434340'
Test #42:
score: 10
Accepted
time: 13ms
memory: 5116kb
input:
99940 -366859 734803 -722883 -352755 266497 350263 892977 -547983 229061 -550941 -253023 -216687 187041 219125 907493 920171 445273 133343 965557 991163 102237 -66815 434577 732831 239757 -263029 -746567 -527277 -350051 879745 -943679 -528263 -928399 -528263 -867279 66295 -696907 -722505 -247675 465...
output:
753304
result:
ok single line: '753304'
Test #43:
score: 10
Accepted
time: 13ms
memory: 5384kb
input:
99940 629940 252040 422661 -727640 847455 297570 -129230 -330430 -539523 962465 267415 639045 -230737 382350 626528 -730 -940433 -799860 -667473 962465 -941286 675155 -880723 467915 727182 -864230 -936168 -94145 608615 697135 -668326 -963925 -947257 201800 -84021 -386950 -882429 735600 -606057 83922...
output:
669605
result:
ok single line: '669605'
Test #44:
score: 10
Accepted
time: 13ms
memory: 5116kb
input:
99831 758237 -429818 616877 504517 482027 -525398 -877633 -183173 773117 659227 89567 -748958 -14593 -305483 -586543 960547 41207 979582 -300103 -4568 493187 778297 -778123 229522 -338233 -273488 96077 -235823 462497 218992 752657 -429818 41207 188617 419717 389902 -245233 478597 878207 229522 -6655...
output:
376650
result:
ok single line: '376650'
Test #45:
score: 10
Accepted
time: 12ms
memory: 5268kb
input:
100000 -185103 330730 640566 330730 -197028 330730 -296469 330730 950535 330730 -436833 330730 -331893 330730 -130545 330730 236349 330730 -462267 330730 -796788 330730 782343 330730 977130 330730 210285 330730 -99909 330730 979830 330730 206793 330730 346842 330730 591111 330730 444690 330730 96783...
output:
-1
result:
ok single line: '-1'
Test #46:
score: 10
Accepted
time: 12ms
memory: 5172kb
input:
100000 897386 -498167 294216 -498167 -416934 -498167 407176 -498167 423246 -498167 -806934 -498167 -106964 -498167 185376 -498167 -17724 -498167 83516 -498167 481156 -498167 795446 -498167 134076 -498167 -338814 -498167 279526 -498167 970276 -498167 844856 -498167 -37134 -498167 -430634 -498167 -954...
output:
-1
result:
ok single line: '-1'
Test #47:
score: 10
Accepted
time: 9ms
memory: 5388kb
input:
100000 302722 467192 -710129 467192 735336 467192 -255381 467192 -822213 467192 -158389 467192 -193270 467192 358540 467192 -219100 467192 558733 467192 -507675 467192 -695590 467192 -409213 467192 -714518 467192 336567 467192 -533925 467192 -773689 467192 -968688 467192 62384 467192 876526 467192 6...
output:
-1
result:
ok single line: '-1'
Test #48:
score: 10
Accepted
time: 12ms
memory: 5360kb
input:
100000 672106 221171 672106 883430 672106 288290 672106 -658799 141374 -131948 141374 158602 141374 309649 141374 650353 141374 642956 141374 -768194 141374 -718417 672106 249667 672106 784734 141374 470511 141374 98035 672106 998389 672106 352965 141374 898640 672106 -536287 672106 -578615 141374 -...
output:
6899516
result:
ok single line: '6899516'
Test #49:
score: 10
Accepted
time: 8ms
memory: 5108kb
input:
100000 -816116 922009 315232 922009 -249356 922009 610000 949351 490680 949351 582100 949351 292220 922009 -987840 949351 595672 922009 -937660 922009 254856 922009 -13192 949351 583064 922009 -350928 922009 -646536 949351 -965832 922009 -193972 949351 -725520 922009 -820104 922009 315472 949351 670...
output:
109368
result:
ok single line: '109368'
Test #50:
score: 10
Accepted
time: 14ms
memory: 5152kb
input:
100000 -400087 361704 168413 -522429 259093 -522429 -133567 361704 -63837 -522429 507753 -522429 327713 361704 -564507 361704 -367307 361704 -783337 361704 -9157 -522429 -827827 -522429 725203 361704 414713 -522429 -125927 361704 877363 361704 812293 361704 -537707 -522429 910523 361704 634733 -5224...
output:
8841330
result:
ok single line: '8841330'
Test #51:
score: 10
Accepted
time: 0ms
memory: 3612kb
input:
1 393683 -129821
output:
-1
result:
ok single line: '-1'
Test #52:
score: 10
Accepted
time: 14ms
memory: 5148kb
input:
99540 40621 884068 577951 239764 -786692 884068 -889682 -915438 820492 -309724 -618176 881224 -464684 -8446 -336083 -615316 -278327 918718 773440 -147292 100609 -406310 594181 -347808 71233 39452 374938 -406310 498904 -276194 877597 797536 259045 305700 853963 605276 -670709 615112 -336083 784766 11...
output:
6
result:
ok single line: '6'
Test #53:
score: 0
Wrong Answer
time: 13ms
memory: 5172kb
input:
99802 605960 -462294 118320 -783465 993870 91908 -864144 -429162 324342 290253 123132 695739 -723136 -925983 -762138 -997044 -580284 -224673 -955872 150849 552280 -842922 993870 -496248 882382 -536550 748448 -118500 936372 -155847 486570 -92055 -545100 -168126 865686 -500748 -362208 740640 -133172 -...
output:
2
result:
wrong answer 1st lines differ - expected: '6', found: '2'
Subtask #4:
score: 0
Wrong Answer
Test #59:
score: 0
Wrong Answer
time: 0ms
memory: 3616kb
input:
5 0 0 1 0 -1 0 0 1 0 -1
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%