QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#457055#3224. DirectionspropaneWA 282ms21852kbC++202.6kb2024-06-28 23:07:332024-06-28 23:07:34

Judging History

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

  • [2024-06-28 23:07:34]
  • 评测
  • 测评结果:WA
  • 用时:282ms
  • 内存:21852kb
  • [2024-06-28 23:07:33]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<numeric>
#include<map>
#include<algorithm>
using namespace std;
using LL = long long;

struct Point{
    LL x, y;

    LL operator*(const Point &t) const {
        return x * t.x + y * t.y;
    }

    LL operator^(const Point &t) const {
        return x * t.y - y * t.x;
    }

    int quad() const {
        if (y < 0) return 1;
        if (y > 0) return 4;
        if (x < 0) return 5;
        if (x > 0) return 2;
        return 3;
    }

    bool operator<(const Point &t) const {
        int q1 = quad(), q2 = t.quad();
        if (q1 != q2) return q1 < q2;
        return (*this ^ t) > 0;
    }

};

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    const LL INF = 1e18;
    int n;
    cin >> n;
    map<Point, int> mp;
    for(int i = 0; i < n; i++){
        LL x, y; int p;
        cin >> x >> y >> p;
        if (x == 0 and y == 0) continue;
        LL g = abs(gcd(x, y));
        x /= g, y /= g;
        if (!mp.contains({x, y})){
            mp[{x, y}] = p;
        }
        else{
            mp[{x, y}] = min(mp[{x, y}], p);
        }
    }
    vector<Point> pt;
    vector<int> p;
    for(auto [x, y] : mp){
        pt.push_back(x);
        p.push_back(y);
    }

    if (pt.empty()){
        cout << -1 << '\n';
        return 0;
    }

    auto rot = [&](Point &s){
        swap(s.x, s.y);
        s.x = -s.x;
    };

    LL ans = INF;

    for(auto s : pt){
        LL sum = mp[s];
        rot(s);
        if (mp.contains(s)){
            sum += mp[s];
        }
        else continue;
        rot(s);
        if (mp.contains(s)){
            sum += mp[s];
        }
        else continue;
        rot(s);
        if (mp.contains(s)){
            sum += mp[s];
        }
        else continue;
        ans = min(ans, sum);
    }

    int mnpos = min_element(p.begin(), p.end()) - p.begin();
    rotate(pt.begin(), pt.begin() + mnpos, pt.end());
    rotate(p.begin(), p.begin() + mnpos, p.end());

    int j = 1;
    while(j < pt.size() and (pt[0] ^ pt[j]) >= 0) j++;

    int ed = 1;
    while(ed < pt.size() and (pt[0] ^ pt[ed]) > 0) ed++;

    j--;
    LL mn = INF;
    for(int i = 1; i < ed; i++){
        while(j + 1 < pt.size() and (pt[i] ^ pt[j + 1]) > 0){
            mn = min(mn, 1LL * p[++j]);
        }
        ans = min(ans, p[0] + p[i] + mn);
    }

    if (ans > INF / 2) ans = -1;
    cout << ans << '\n';
}

详细

Test #1:

score: 100
Accepted
time: 25ms
memory: 3664kb

input:

200000
-1 -1 1
1 1 1
0 1 1
1 0 1
1 -1 1
1 1 1
1 1 1
-1 1 1
1 -1 1
0 1 1
0 0 1
0 0 1
1 -1 1
-1 -1 1
0 0 1
1 0 1
-1 1 1
-1 1 1
1 1 1
1 1 1
-1 1 1
0 -1 1
1 -1 1
-1 0 1
1 0 1
1 -1 1
0 -1 1
1 0 1
-1 1 1
1 0 1
-1 0 1
1 1 1
1 0 1
-1 -1 1
-1 1 1
-1 -1 1
0 -1 1
0 -1 1
1 1 1
1 -1 1
0 1 1
1 1 1
-1 1 1
1 -1 1
0...

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 22ms
memory: 3636kb

input:

200000
-1 -1 2
1 0 1
1 0 2
1 -1 2
1 0 1
-1 1 1
-1 -1 2
1 1 1
0 -1 2
-1 -1 1
0 1 2
0 -1 2
-1 0 2
0 0 2
-1 1 1
1 1 1
-1 0 1
1 -1 2
1 0 1
0 0 1
1 0 2
0 -1 1
0 1 1
0 -1 2
-1 1 2
0 1 2
-1 1 2
0 1 1
0 1 1
1 1 2
1 1 1
1 0 2
1 1 2
-1 1 2
-1 1 1
0 1 2
0 -1 2
1 0 2
0 1 1
0 -1 1
1 -1 1
1 0 2
0 -1 1
-1 0 1
0 -1...

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 31ms
memory: 3632kb

input:

200000
1 0 555860533
-1 1 633479355
0 0 411890838
-1 -1 411764668
0 0 324117889
1 1 147426106
1 0 41681213
1 -1 169580394
1 -1 204074237
-1 1 265787176
1 -1 204010614
0 -1 582574240
0 -1 98238758
1 1 489573021
-1 1 747647275
1 -1 933893240
0 -1 663924164
0 0 470849190
1 -1 479419247
-1 -1 53695974
0...

output:

95355

result:

ok single line: '95355'

Test #4:

score: 0
Accepted
time: 29ms
memory: 3568kb

input:

200000
-1 0 1
-2 2 1
0 0 1
1 1 1
2 -2 1
0 2 1
-1 -1 1
0 0 1
1 1 1
2 1 1
0 1 1
-2 -1 1
-1 -1 1
-2 2 1
-1 -2 1
0 0 1
-2 0 1
2 1 1
1 -2 1
1 -2 1
-1 -2 1
0 1 1
0 -1 1
1 -2 1
0 1 1
2 0 1
-1 1 1
1 0 1
2 -2 1
-1 2 1
-2 1 1
-1 0 1
2 1 1
0 1 1
-1 -1 1
0 2 1
2 2 1
2 -2 1
1 -2 1
-2 0 1
-2 -2 1
-2 1 1
1 2 1
2 -...

output:

3

result:

ok single line: '3'

Test #5:

score: 0
Accepted
time: 28ms
memory: 3516kb

input:

200000
-2 1 2
2 1 2
1 -1 2
1 2 2
-1 2 1
1 -1 2
1 -1 2
-2 -1 2
1 2 1
2 -1 2
0 1 2
1 -1 1
-2 2 1
-2 1 2
-1 0 2
2 0 1
1 -2 2
-1 1 1
1 -2 1
-2 1 2
-1 1 2
2 -2 1
-2 1 2
-2 1 1
-2 2 1
0 -2 1
2 -2 2
0 2 2
2 2 2
2 2 2
0 2 2
-2 2 2
1 -2 1
1 0 2
-1 -2 1
-2 1 2
0 -1 1
2 0 1
-1 -1 2
1 -2 1
-2 -2 1
1 -1 2
-2 2 1...

output:

3

result:

ok single line: '3'

Test #6:

score: 0
Accepted
time: 33ms
memory: 3636kb

input:

200000
-1 -2 29368112
2 -1 24391896
0 -2 58495223
0 1 266081519
-2 -2 381375524
2 1 738559870
2 -2 407460939
-1 1 562555301
-2 2 185971753
2 -1 886154605
1 1 842679105
1 0 300033644
2 1 430527773
-1 -1 295205658
-1 2 903654949
-2 2 674980542
2 -2 725974565
0 1 924537846
-2 1 828956777
0 2 145229295
...

output:

50007

result:

ok single line: '50007'

Test #7:

score: 0
Accepted
time: 26ms
memory: 3568kb

input:

200000
-1 1 1
2 0 1
-2 2 1
-2 -2 1
-1 -1 1
1 0 1
1 -1 1
1 -1 1
2 0 1
2 -2 1
-3 -1 1
-1 3 1
0 0 1
2 3 1
-2 -1 1
3 0 1
-1 -3 1
-1 -1 1
-3 1 1
-1 0 1
-1 -3 1
-1 0 1
2 3 1
-3 3 1
-1 2 1
-3 0 1
3 2 1
-2 1 1
-2 -2 1
2 3 1
2 3 1
-3 -3 1
2 3 1
1 -1 1
-1 -2 1
1 1 1
-3 1 1
-2 0 1
-1 -3 1
1 -2 1
-2 0 1
1 -1 1
...

output:

3

result:

ok single line: '3'

Test #8:

score: 0
Accepted
time: 30ms
memory: 3624kb

input:

200000
-1 3 2
-2 -2 2
1 -3 2
3 0 2
3 -3 1
2 1 1
-1 -3 2
0 0 2
1 0 2
1 0 1
-1 -1 2
1 2 2
-1 1 2
0 2 1
0 3 2
3 0 2
-1 -2 1
-3 -2 2
0 0 1
-3 -2 2
3 1 2
3 0 1
-2 2 1
-1 0 2
3 3 1
0 3 2
1 -1 1
-2 0 1
1 -1 2
2 3 2
-3 -3 1
2 0 2
0 -2 2
3 0 1
3 -2 2
-1 2 1
-1 0 2
1 2 1
2 1 1
1 -1 2
1 -1 1
-2 -1 2
0 -3 2
-1 ...

output:

3

result:

ok single line: '3'

Test #9:

score: 0
Accepted
time: 32ms
memory: 3568kb

input:

200000
1 -3 518137122
2 0 834424887
-3 -2 231423111
1 -2 504370653
0 -1 410088110
1 -3 604634228
0 -1 778458743
-2 0 372225547
-3 -3 213186092
-1 3 217495508
-1 0 897781531
-1 3 890144466
0 0 174193369
2 -2 392192299
3 -3 664301085
-1 2 394866190
3 -2 923710269
-1 -1 601337929
1 -3 519383120
0 -1 18...

output:

55780

result:

ok single line: '55780'

Test #10:

score: 0
Accepted
time: 34ms
memory: 3880kb

input:

200000
-6 7 1
1 -5 1
-5 -5 1
-1 3 1
-4 5 1
9 0 1
-2 -10 1
6 9 1
9 8 1
8 -3 1
0 3 1
-7 -7 1
1 9 1
3 -3 1
-5 -6 1
-9 5 1
-9 0 1
8 8 1
-2 -9 1
0 8 1
-10 2 1
1 -5 1
6 -7 1
4 3 1
4 -6 1
-9 10 1
-2 -1 1
9 8 1
-8 7 1
3 -6 1
0 10 1
0 10 1
-10 6 1
3 -9 1
8 -10 1
-5 6 1
-1 6 1
0 2 1
-1 -5 1
6 8 1
1 -9 1
8 4 1...

output:

3

result:

ok single line: '3'

Test #11:

score: 0
Accepted
time: 38ms
memory: 3892kb

input:

200000
6 -8 2
-5 9 2
0 -4 2
-2 -9 1
7 8 2
10 8 2
-5 5 2
4 3 1
-8 -7 2
-1 0 1
-2 -3 1
-9 -6 1
10 7 2
1 -8 2
-3 -4 2
-8 9 1
5 -3 2
-10 -5 2
-8 10 2
2 -7 2
7 -8 1
-9 -1 2
-4 6 2
-2 10 2
3 0 1
-7 2 1
-2 10 2
9 4 2
-9 9 2
9 -5 1
4 -4 1
8 2 1
-1 8 1
6 -9 2
-1 7 1
-8 7 1
-6 7 1
-6 -4 1
4 8 1
-9 8 2
-7 -8 1...

output:

3

result:

ok single line: '3'

Test #12:

score: 0
Accepted
time: 42ms
memory: 3540kb

input:

200000
1 -9 868328714
1 -2 169338841
2 -3 522935877
7 4 846334853
6 3 95747102
2 8 683463453
-3 10 674070722
7 5 879124379
9 7 411799557
-6 5 452823389
10 0 460945667
-5 -10 384988883
-4 10 944711005
-8 -6 540403661
6 0 804621844
-5 9 121613673
10 -3 854883852
7 -5 776415902
0 9 555825703
-6 -5 2637...

output:

49548

result:

ok single line: '49548'

Test #13:

score: 0
Accepted
time: 272ms
memory: 21412kb

input:

200000
-712994576 681957216 1
742214757 -749366118 1
643431902 -900788690 1
490499102 469176533 1
274934881 224980485 1
66532381 -860911586 1
776002355 -154470536 1
837312330 -571543374 1
971536663 -630853477 1
116903881 442223660 1
667716471 -828182152 1
336272958 -251409255 1
503068146 763971728 1...

output:

3

result:

ok single line: '3'

Test #14:

score: 0
Accepted
time: 282ms
memory: 21852kb

input:

200000
-602008984 693387889 1
897189880 -803134494 1
35887395 374199573 1
97436871 -310842124 2
-317640064 -574779803 1
-295972377 43817547 2
340192254 370024590 1
-78314559 -497366938 2
664758677 345537889 2
-631188522 -421590323 2
916801468 87978323 2
-392373838 89334600 1
993337752 798186512 2
-6...

output:

3

result:

ok single line: '3'

Test #15:

score: 0
Accepted
time: 276ms
memory: 21164kb

input:

200000
624731001 -756312895 732418025
-723028405 454048115 884229821
657008140 -126241037 451702065
-299325474 365545215 62086888
694524222 901018738 927667060
-806668501 548329101 564050553
162465309 -226915270 370979883
357761925 4184566 129493846
718751910 -547636756 397742261
-413240751 -9747541...

output:

31001

result:

ok single line: '31001'

Test #16:

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

input:

1
0 0 1

output:

-1

result:

ok single line: '-1'

Test #17:

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

input:

1
1 0 2

output:

-1

result:

ok single line: '-1'

Test #18:

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

input:

1
0 -1 463167712

output:

-1

result:

ok single line: '-1'

Test #19:

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

input:

1
0 -2 1

output:

-1

result:

ok single line: '-1'

Test #20:

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

input:

1
0 -1 2

output:

-1

result:

ok single line: '-1'

Test #21:

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

input:

1
1 0 918809706

output:

-1

result:

ok single line: '-1'

Test #22:

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

input:

1
0 -1 1

output:

-1

result:

ok single line: '-1'

Test #23:

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

input:

1
3 1 1

output:

-1

result:

ok single line: '-1'

Test #24:

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

input:

1
-3 3 104127434

output:

-1

result:

ok single line: '-1'

Test #25:

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

input:

1
-8 5 1

output:

-1

result:

ok single line: '-1'

Test #26:

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

input:

1
5 -9 2

output:

-1

result:

ok single line: '-1'

Test #27:

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

input:

1
-7 7 716743621

output:

-1

result:

ok single line: '-1'

Test #28:

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

input:

1
357462890 848080022 1

output:

-1

result:

ok single line: '-1'

Test #29:

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

input:

1
887520827 -701989688 2

output:

-1

result:

ok single line: '-1'

Test #30:

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

input:

1
-170868300 -940219117 849841157

output:

-1

result:

ok single line: '-1'

Test #31:

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

input:

2
1 0 1
1 0 1

output:

-1

result:

ok single line: '-1'

Test #32:

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

input:

2
-1 -1 2
0 1 2

output:

-1

result:

ok single line: '-1'

Test #33:

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

input:

2
0 0 913090376
-1 -1 541928148

output:

-1

result:

ok single line: '-1'

Test #34:

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

input:

2
-2 1 1
-1 -1 1

output:

-1

result:

ok single line: '-1'

Test #35:

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

input:

2
2 -2 2
2 0 1

output:

-1

result:

ok single line: '-1'

Test #36:

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

input:

2
0 -1 705463868
-2 1 130111370

output:

-1

result:

ok single line: '-1'

Test #37:

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

input:

2
0 -3 1
-3 2 1

output:

-1

result:

ok single line: '-1'

Test #38:

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

input:

2
-3 2 1
3 -2 1

output:

-1

result:

ok single line: '-1'

Test #39:

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

input:

2
2 2 122302093
-2 -2 828026820

output:

-1

result:

ok single line: '-1'

Test #40:

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

input:

2
-5 10 1
-5 2 1

output:

-1

result:

ok single line: '-1'

Test #41:

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

input:

2
1 -5 2
9 5 1

output:

-1

result:

ok single line: '-1'

Test #42:

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

input:

2
-10 -5 31542690
-5 3 129473093

output:

-1

result:

ok single line: '-1'

Test #43:

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

input:

2
266809570 381130972 1
-890632596 454834668 1

output:

-1

result:

ok single line: '-1'

Test #44:

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

input:

2
236002924 544226705 1
-8930666 633728962 1

output:

-1

result:

ok single line: '-1'

Test #45:

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

input:

2
-997831104 237273816 438836317
-754753844 -855592460 577498221

output:

-1

result:

ok single line: '-1'

Test #46:

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

input:

3
1 -1 1
-1 -1 1
0 1 1

output:

3

result:

ok single line: '3'

Test #47:

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

input:

3
0 1 1
0 0 1
1 -1 2

output:

-1

result:

ok single line: '-1'

Test #48:

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

input:

3
1 1 364170638
0 1 112013377
-1 0 644196224

output:

-1

result:

ok single line: '-1'

Test #49:

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

input:

3
2 -1 1
2 0 1
1 -2 1

output:

-1

result:

ok single line: '-1'

Test #50:

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

input:

3
-2 -1 2
1 -2 2
-2 0 2

output:

-1

result:

ok single line: '-1'

Test #51:

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

input:

3
1 -1 367635035
0 -1 501995671
1 0 122350696

output:

-1

result:

ok single line: '-1'

Test #52:

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

input:

3
3 3 1
-3 -2 1
3 2 1

output:

-1

result:

ok single line: '-1'

Test #53:

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

input:

3
-1 -2 2
-1 0 2
1 3 1

output:

-1

result:

ok single line: '-1'

Test #54:

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

input:

3
2 -1 871260078
0 0 48868055
-2 3 678301346

output:

-1

result:

ok single line: '-1'

Test #55:

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

input:

3
-6 -4 1
-9 -3 1
2 -7 1

output:

-1

result:

ok single line: '-1'

Test #56:

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

input:

3
-4 9 1
-2 -5 1
-10 -5 1

output:

-1

result:

ok single line: '-1'

Test #57:

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

input:

3
-7 -7 869722287
3 4 494803269
1 -1 992571956

output:

2357097512

result:

ok single line: '2357097512'

Test #58:

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

input:

3
-289202947 -933105008 1
854736853 695493895 1
-839793012 321062172 1

output:

3

result:

ok single line: '3'

Test #59:

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

input:

3
-997919395 -44651903 2
-575930672 881718329 1
10157454 -725678725 2

output:

-1

result:

ok single line: '-1'

Test #60:

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

input:

3
-153974995 -733280733 18571221
-700358990 851291676 383127291
-97978411 -351707387 499070162

output:

-1

result:

ok single line: '-1'

Test #61:

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

input:

4
1 0 1
1 1 1
-1 1 1
0 0 1

output:

-1

result:

ok single line: '-1'

Test #62:

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

input:

4
1 -1 1
0 1 1
0 -1 1
1 1 2

output:

-1

result:

ok single line: '-1'

Test #63:

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

input:

4
1 0 424912797
1 1 20014826
-1 1 236445860
-1 0 945826160

output:

-1

result:

ok single line: '-1'

Test #64:

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

input:

4
0 -1 1
0 2 1
-1 -1 1
2 1 1

output:

3

result:

ok single line: '3'

Test #65:

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

input:

4
-2 2 2
1 1 2
0 0 2
1 1 1

output:

-1

result:

ok single line: '-1'

Test #66:

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

input:

4
-1 0 876759264
2 -1 829927108
1 0 639182840
2 -1 873348938

output:

-1

result:

ok single line: '-1'

Test #67:

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

input:

4
-1 3 1
0 -3 1
0 0 1
-2 0 1

output:

-1

result:

ok single line: '-1'

Test #68:

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

input:

4
2 3 2
3 2 1
-3 -2 1
0 -2 2

output:

5

result:

ok single line: '5'

Test #69:

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

input:

4
-1 1 479709005
0 0 629128474
-1 -2 401828193
1 -3 859823602

output:

-1

result:

ok single line: '-1'

Test #70:

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

input:

4
-10 3 1
5 3 1
-8 -4 1
-4 4 1

output:

-1

result:

ok single line: '-1'

Test #71:

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

input:

4
8 10 2
9 7 2
8 -7 2
-8 3 2

output:

6

result:

ok single line: '6'

Test #72:

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

input:

4
-9 -10 981747466
-2 5 628608354
-6 -3 507929909
3 -5 357833106

output:

1494371369

result:

ok single line: '1494371369'

Test #73:

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

input:

4
40409828 -930958911 1
-306359436 -568724956 1
-381156596 909241901 1
-515918651 -353432539 1

output:

-1

result:

ok single line: '-1'

Test #74:

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

input:

4
57108381 -484752235 2
-669727261 -84683717 1
-753877938 -825438490 2
-542675079 289658193 2

output:

-1

result:

ok single line: '-1'

Test #75:

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

input:

4
137296340 112516375 713084296
-848344371 240288422 940588554
161989482 -447300590 247982323
-190935573 -60214699 103730734

output:

1064797353

result:

ok single line: '1064797353'

Test #76:

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

input:

5
0 -1 1
-1 1 1
-1 -1 1
0 -1 1
0 0 1

output:

-1

result:

ok single line: '-1'

Test #77:

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

input:

5
0 0 1
0 1 2
1 1 2
0 -1 1
1 0 2

output:

-1

result:

ok single line: '-1'

Test #78:

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

input:

5
1 1 909578372
-1 -1 797960423
0 0 919126291
-1 -1 984885911
0 0 467926433

output:

-1

result:

ok single line: '-1'

Test #79:

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

input:

5
2 0 1
2 -1 1
2 0 1
1 -1 1
-2 -2 1

output:

-1

result:

ok single line: '-1'

Test #80:

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

input:

5
-2 -1 2
2 -1 2
0 0 1
-2 -2 1
0 2 2

output:

5

result:

ok single line: '5'

Test #81:

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

input:

5
-2 -2 319653153
0 -1 872033505
2 1 383729842
-2 -2 17774667
-1 0 165152683

output:

566657192

result:

ok single line: '566657192'

Test #82:

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

input:

5
1 0 1
0 2 1
-3 -3 1
-1 1 1
0 2 1

output:

3

result:

ok single line: '3'

Test #83:

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

input:

5
2 0 1
1 -1 2
2 -3 1
2 0 2
-2 2 2

output:

4

result:

ok single line: '4'

Test #84:

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

input:

5
0 -2 711372153
2 -3 347595781
1 0 677079331
-2 3 848024951
1 1 178959083

output:

1738356187

result:

ok single line: '1738356187'

Test #85:

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

input:

5
-8 2 1
3 -9 1
3 -9 1
8 -9 1
-2 9 1

output:

3

result:

ok single line: '3'

Test #86:

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

input:

5
9 -6 2
2 5 2
1 5 2
3 -1 1
-2 8 1

output:

-1

result:

ok single line: '-1'

Test #87:

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

input:

5
-1 -8 571622347
-9 7 961921376
3 -9 609024960
-5 4 431471558
10 -1 739516883

output:

1742610788

result:

ok single line: '1742610788'

Test #88:

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

input:

5
241093338 761753689 1
-219177331 443645520 1
-739588414 -501966547 1
207658970 81022336 1
-91883013 679905226 1

output:

3

result:

ok single line: '3'

Test #89:

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

input:

5
19632632 658860759 2
877417220 -905289388 1
-855267998 214883245 1
-3901737 559283581 2
-17163160 512580778 1

output:

3

result:

ok single line: '3'

Test #90:

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

input:

5
509963035 -856536742 441345314
959711404 -4160027 589498865
-793188395 775088773 18649416
12978049 631750823 723999149
2585751 -382304178 609044806

output:

1049493595

result:

ok single line: '1049493595'

Test #91:

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

input:

6
-1 -1 1
-1 -1 1
-1 0 1
1 -1 1
1 0 1
0 1 1

output:

3

result:

ok single line: '3'

Test #92:

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

input:

6
0 0 1
0 -1 2
-1 -1 2
1 1 2
1 -1 1
0 1 2

output:

5

result:

ok single line: '5'

Test #93:

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

input:

6
0 -1 764268751
0 -1 129079919
1 1 380199209
0 1 256579616
1 -1 490977212
1 0 662123675

output:

-1

result:

ok single line: '-1'

Test #94:

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

input:

6
-2 1 1
-1 0 1
2 2 1
1 -1 1
2 1 1
1 -2 1

output:

3

result:

ok single line: '3'

Test #95:

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

input:

6
2 1 2
-1 2 2
2 1 2
0 0 1
-1 0 2
2 2 1

output:

-1

result:

ok single line: '-1'

Test #96:

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

input:

6
0 -1 881987471
2 -2 783402192
1 -2 810766466
-2 0 138592311
-2 -1 922394100
2 -2 50644647

output:

-1

result:

ok single line: '-1'

Test #97:

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

input:

6
-3 -3 1
-3 3 1
1 1 1
2 3 1
0 2 1
-3 -3 1

output:

-1

result:

ok single line: '-1'

Test #98:

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

input:

6
-2 1 1
-3 2 2
0 0 1
2 2 1
1 -3 1
-2 3 2

output:

3

result:

ok single line: '3'

Test #99:

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

input:

6
1 2 308964686
-3 3 539845608
0 2 428873525
-2 -2 559765548
-1 -1 230919598
1 1 579221044

output:

-1

result:

ok single line: '-1'

Test #100:

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

input:

6
4 -10 1
2 -10 1
-4 -10 1
-4 -7 1
10 -3 1
-1 8 1

output:

3

result:

ok single line: '3'

Test #101:

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

input:

6
-10 -10 2
8 4 2
5 5 2
-6 3 1
-4 -10 2
-1 -4 2

output:

5

result:

ok single line: '5'

Test #102:

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

input:

6
10 3 358045696
3 6 690825516
-4 7 34937545
-10 7 780224907
4 -10 112724666
-3 3 36700085

output:

505707907

result:

ok single line: '505707907'

Test #103:

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

input:

6
631629425 846478667 1
-38551900 620286355 1
-212085538 377796842 1
-556455437 -564322785 1
-372351569 -224033061 1
-793464907 457684656 1

output:

-1

result:

ok single line: '-1'

Test #104:

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

input:

6
734737825 -194536234 1
850360651 161538691 2
406589698 -457745554 2
840721672 109116201 1
-329569741 94200402 1
-186533965 393325015 2

output:

4

result:

ok single line: '4'

Test #105:

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

input:

6
910571417 -792067175 309531353
658887 714765192 377241199
-548462164 777244559 929591595
-65121734 301037581 507959808
28494698 -388896274 388857123
-872526474 -756310299 25205020

output:

711977572

result:

ok single line: '711977572'

Test #106:

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

input:

7
1 1 1
-1 0 1
-1 0 1
0 0 1
1 0 1
1 0 1
-1 0 1

output:

-1

result:

ok single line: '-1'

Test #107:

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

input:

7
0 -1 1
0 0 1
0 0 2
0 0 1
-1 -1 2
-1 1 2
1 -1 2

output:

-1

result:

ok single line: '-1'

Test #108:

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

input:

7
-1 -1 126734705
1 0 456838175
1 0 604936582
0 1 353268033
1 0 193350950
1 -1 386750602
1 -1 794864868

output:

673353688

result:

ok single line: '673353688'

Test #109:

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

input:

7
-2 -2 1
1 -2 1
-2 2 1
-1 -2 1
2 -2 1
2 0 1
2 1 1

output:

3

result:

ok single line: '3'

Test #110:

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

input:

7
0 -1 1
2 -2 2
2 -2 1
-1 -2 1
-2 0 1
2 0 2
2 -1 2

output:

-1

result:

ok single line: '-1'

Test #111:

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

input:

7
0 -2 248752882
-1 -2 809054551
-2 -1 63768205
2 0 695280890
1 1 323099724
2 -1 79193533
-1 -2 27856316

output:

414724245

result:

ok single line: '414724245'

Test #112:

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

input:

7
3 1 1
-2 2 1
2 -1 1
2 -2 1
3 -1 1
-1 3 1
-1 3 1

output:

-1

result:

ok single line: '-1'

Test #113:

score: -100
Wrong Answer
time: 0ms
memory: 3568kb

input:

7
2 -3 1
-3 -3 1
2 2 1
2 0 2
-2 2 1
-1 1 1
-3 -2 2

output:

4

result:

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