Submission #547458

# Submission time Handle Problem Language Result Execution time Memory
547458 2022-04-10T18:46:41 Z duality Team Contest (JOI22_team) C++17
100 / 100
659 ms 29100 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int a[150000][3];
vpii v[3];
int del[150000],num[150000];
multiset<int> S[3];
queue<int> Q;
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);

    int j;
    for (i = 0; i < N; i++) {
        for (j = 0; j < 3; j++) v[j].pb(mp(a[i][j],i)),S[j].insert(a[i][j]);
    }
    int p[3];
    p[0] = p[1] = p[2] = N-1;
    for (i = 0; i < 3; i++) S[i].insert(-1),sort(v[i].begin(),v[i].end());
    for (i = 0; i < 3; i++) {
        while ((p[i] >= 0) && (v[i][p[i]].first >= *S[i].rbegin())) {
            num[v[i][p[i]].second]++;
            if (num[v[i][p[i]].second] >= 2) Q.push(v[i][p[i]].second);
            p[i]--;
        }
    }
    while (!Q.empty()) {
        int u = Q.front();
        Q.pop();

        if (!del[u]) {
            del[u] = 1;
            for (i = 0; i < 3; i++) S[i].erase(S[i].find(a[u][i]));
            for (i = 0; i < 3; i++) {
                while ((p[i] >= 0) && (v[i][p[i]].first >= *S[i].rbegin())) {
                    num[v[i][p[i]].second]++;
                    if (num[v[i][p[i]].second] >= 2) Q.push(v[i][p[i]].second);
                    p[i]--;
                }
            }
        }
    }
    if (S[0].size() == 1) printf("-1\n");
    else printf("%d\n",*S[0].rbegin()+*S[1].rbegin()+*S[2].rbegin());

    return 0;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:66:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
team.cpp:67:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |     for (i = 0; i < N; i++) scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 392 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 392 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 5 ms 980 KB Output is correct
27 Correct 5 ms 980 KB Output is correct
28 Correct 5 ms 980 KB Output is correct
29 Correct 6 ms 980 KB Output is correct
30 Correct 4 ms 724 KB Output is correct
31 Correct 5 ms 980 KB Output is correct
32 Correct 8 ms 980 KB Output is correct
33 Correct 5 ms 980 KB Output is correct
34 Correct 7 ms 980 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 4 ms 956 KB Output is correct
38 Correct 6 ms 1048 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 284 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 214 ms 27944 KB Output is correct
12 Correct 181 ms 18752 KB Output is correct
13 Correct 162 ms 22952 KB Output is correct
14 Correct 277 ms 27996 KB Output is correct
15 Correct 218 ms 28652 KB Output is correct
16 Correct 180 ms 29040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 284 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 214 ms 27944 KB Output is correct
12 Correct 181 ms 18752 KB Output is correct
13 Correct 162 ms 22952 KB Output is correct
14 Correct 277 ms 27996 KB Output is correct
15 Correct 218 ms 28652 KB Output is correct
16 Correct 180 ms 29040 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 246 ms 27808 KB Output is correct
23 Correct 302 ms 27244 KB Output is correct
24 Correct 212 ms 20284 KB Output is correct
25 Correct 331 ms 27884 KB Output is correct
26 Correct 291 ms 28700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 284 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 214 ms 27944 KB Output is correct
12 Correct 181 ms 18752 KB Output is correct
13 Correct 162 ms 22952 KB Output is correct
14 Correct 277 ms 27996 KB Output is correct
15 Correct 218 ms 28652 KB Output is correct
16 Correct 180 ms 29040 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 246 ms 27808 KB Output is correct
23 Correct 302 ms 27244 KB Output is correct
24 Correct 212 ms 20284 KB Output is correct
25 Correct 331 ms 27884 KB Output is correct
26 Correct 291 ms 28700 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 6 ms 1068 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 596 KB Output is correct
34 Correct 315 ms 25944 KB Output is correct
35 Correct 315 ms 25288 KB Output is correct
36 Correct 411 ms 27880 KB Output is correct
37 Correct 440 ms 27652 KB Output is correct
38 Correct 283 ms 27936 KB Output is correct
39 Correct 131 ms 16792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 284 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 214 ms 27944 KB Output is correct
12 Correct 181 ms 18752 KB Output is correct
13 Correct 162 ms 22952 KB Output is correct
14 Correct 277 ms 27996 KB Output is correct
15 Correct 218 ms 28652 KB Output is correct
16 Correct 180 ms 29040 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 246 ms 27808 KB Output is correct
23 Correct 302 ms 27244 KB Output is correct
24 Correct 212 ms 20284 KB Output is correct
25 Correct 331 ms 27884 KB Output is correct
26 Correct 291 ms 28700 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 6 ms 1068 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 596 KB Output is correct
34 Correct 315 ms 25944 KB Output is correct
35 Correct 315 ms 25288 KB Output is correct
36 Correct 411 ms 27880 KB Output is correct
37 Correct 440 ms 27652 KB Output is correct
38 Correct 283 ms 27936 KB Output is correct
39 Correct 131 ms 16792 KB Output is correct
40 Correct 3 ms 724 KB Output is correct
41 Correct 5 ms 980 KB Output is correct
42 Correct 5 ms 1004 KB Output is correct
43 Correct 5 ms 1056 KB Output is correct
44 Correct 433 ms 26984 KB Output is correct
45 Correct 659 ms 27876 KB Output is correct
46 Correct 612 ms 28028 KB Output is correct
47 Correct 627 ms 27900 KB Output is correct
48 Correct 301 ms 28764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 392 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 5 ms 980 KB Output is correct
27 Correct 5 ms 980 KB Output is correct
28 Correct 5 ms 980 KB Output is correct
29 Correct 6 ms 980 KB Output is correct
30 Correct 4 ms 724 KB Output is correct
31 Correct 5 ms 980 KB Output is correct
32 Correct 8 ms 980 KB Output is correct
33 Correct 5 ms 980 KB Output is correct
34 Correct 7 ms 980 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 4 ms 956 KB Output is correct
38 Correct 6 ms 1048 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 284 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 214 ms 27944 KB Output is correct
51 Correct 181 ms 18752 KB Output is correct
52 Correct 162 ms 22952 KB Output is correct
53 Correct 277 ms 27996 KB Output is correct
54 Correct 218 ms 28652 KB Output is correct
55 Correct 180 ms 29040 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 2 ms 596 KB Output is correct
61 Correct 246 ms 27808 KB Output is correct
62 Correct 302 ms 27244 KB Output is correct
63 Correct 212 ms 20284 KB Output is correct
64 Correct 331 ms 27884 KB Output is correct
65 Correct 291 ms 28700 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 6 ms 1068 KB Output is correct
71 Correct 1 ms 468 KB Output is correct
72 Correct 2 ms 596 KB Output is correct
73 Correct 315 ms 25944 KB Output is correct
74 Correct 315 ms 25288 KB Output is correct
75 Correct 411 ms 27880 KB Output is correct
76 Correct 440 ms 27652 KB Output is correct
77 Correct 283 ms 27936 KB Output is correct
78 Correct 131 ms 16792 KB Output is correct
79 Correct 3 ms 724 KB Output is correct
80 Correct 5 ms 980 KB Output is correct
81 Correct 5 ms 1004 KB Output is correct
82 Correct 5 ms 1056 KB Output is correct
83 Correct 433 ms 26984 KB Output is correct
84 Correct 659 ms 27876 KB Output is correct
85 Correct 612 ms 28028 KB Output is correct
86 Correct 627 ms 27900 KB Output is correct
87 Correct 301 ms 28764 KB Output is correct
88 Correct 394 ms 26720 KB Output is correct
89 Correct 424 ms 27900 KB Output is correct
90 Correct 417 ms 27800 KB Output is correct
91 Correct 491 ms 27856 KB Output is correct
92 Correct 497 ms 27852 KB Output is correct
93 Correct 513 ms 27940 KB Output is correct
94 Correct 525 ms 28128 KB Output is correct
95 Correct 401 ms 28576 KB Output is correct
96 Correct 266 ms 27876 KB Output is correct
97 Correct 197 ms 29100 KB Output is correct
98 Correct 154 ms 26696 KB Output is correct
99 Correct 220 ms 27912 KB Output is correct