답안 #587804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587804 2022-07-02T11:39:09 Z Red_Inside Team Contest (JOI22_team) C++17
100 / 100
207 ms 12620 KB
//
#include <bits/stdc++.h>

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long

using namespace std;
const int maxn=3e5+10,LOG=17, mod=1e9+7;
int block = 320, timer = 0;
const ld EPS = 1e-18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define bt(i) (1 << (i))
#define int ll
const int inf=2e18;
#define y1 yy
#define prev pre
#define pii pair <int, int>

int n, a[maxn], b[maxn], c[maxn], uk[5], ind[5][maxn], ban[maxn];

bool cmp1(int i, int j)
{
	return a[i] > a[j];
}

bool cmp2(int i, int j)
{
	return b[i] > b[j];
}

bool cmp3(int i, int j)
{
	return c[i] > c[j];
}

main()
{
	cin >> n;
	forn(1, i, n)
	{
		cin >> a[i] >> b[i] >> c[i];
		ind[1][i] = i;
		ind[2][i] = i;
		ind[3][i] = i;
	}
	sort(ind[1] + 1, ind[1] + 1 + n, cmp1);
	sort(ind[2] + 1, ind[2] + 1 + n, cmp2);
	sort(ind[3] + 1, ind[3] + 1 + n, cmp3);
	while(true)
	{
		while(uk[1] <= n && ban[ind[1][uk[1]]])
		{
			uk[1]++;
		}
		while(uk[2] <= n && ban[ind[2][uk[2]]])
		{
			uk[2]++;
		}
		while(uk[3] <= n && ban[ind[3][uk[3]]])
		{
			uk[3]++;
		}
		if(uk[1] > n || uk[2] > n || uk[3] > n)
		{
			cout << -1;
			return 0;
		}
		if(b[ind[1][uk[1]]] == b[ind[2][uk[2]]] || 
		c[ind[1][uk[1]]] == c[ind[3][uk[3]]])
		{
			ban[ind[1][uk[1]]] = 1;
			continue;
		}
		if(a[ind[2][uk[2]]] == a[ind[1][uk[1]]] || 
		c[ind[2][uk[2]]] == c[ind[3][uk[3]]])
		{
			ban[ind[2][uk[2]]] = 1;
			continue;
		}
		if(a[ind[3][uk[3]]] == a[ind[1][uk[1]]] || 
		b[ind[3][uk[3]]] == b[ind[2][uk[2]]])
		{
			ban[ind[3][uk[3]]] = 1;
			continue;
		}
		cout << a[ind[1][uk[1]]] + b[ind[2][uk[2]]] + c[ind[3][uk[3]]];
		return 0;
	}
}

Compilation message

team.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 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 0 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 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 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 0 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 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 5 ms 468 KB Output is correct
29 Correct 5 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 3 ms 532 KB Output is correct
32 Correct 3 ms 468 KB Output is correct
33 Correct 4 ms 468 KB Output is correct
34 Correct 7 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
38 Correct 3 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 75 ms 7348 KB Output is correct
12 Correct 53 ms 5768 KB Output is correct
13 Correct 59 ms 7012 KB Output is correct
14 Correct 79 ms 8456 KB Output is correct
15 Correct 72 ms 8484 KB Output is correct
16 Correct 71 ms 8524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 75 ms 7348 KB Output is correct
12 Correct 53 ms 5768 KB Output is correct
13 Correct 59 ms 7012 KB Output is correct
14 Correct 79 ms 8456 KB Output is correct
15 Correct 72 ms 8484 KB Output is correct
16 Correct 71 ms 8524 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 98 ms 8076 KB Output is correct
23 Correct 80 ms 9068 KB Output is correct
24 Correct 68 ms 7028 KB Output is correct
25 Correct 96 ms 9248 KB Output is correct
26 Correct 83 ms 9300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 75 ms 7348 KB Output is correct
12 Correct 53 ms 5768 KB Output is correct
13 Correct 59 ms 7012 KB Output is correct
14 Correct 79 ms 8456 KB Output is correct
15 Correct 72 ms 8484 KB Output is correct
16 Correct 71 ms 8524 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 98 ms 8076 KB Output is correct
23 Correct 80 ms 9068 KB Output is correct
24 Correct 68 ms 7028 KB Output is correct
25 Correct 96 ms 9248 KB Output is correct
26 Correct 83 ms 9300 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 ms 576 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 111 ms 7764 KB Output is correct
35 Correct 103 ms 8452 KB Output is correct
36 Correct 122 ms 9320 KB Output is correct
37 Correct 125 ms 9224 KB Output is correct
38 Correct 99 ms 9120 KB Output is correct
39 Correct 60 ms 5976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 75 ms 7348 KB Output is correct
12 Correct 53 ms 5768 KB Output is correct
13 Correct 59 ms 7012 KB Output is correct
14 Correct 79 ms 8456 KB Output is correct
15 Correct 72 ms 8484 KB Output is correct
16 Correct 71 ms 8524 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 98 ms 8076 KB Output is correct
23 Correct 80 ms 9068 KB Output is correct
24 Correct 68 ms 7028 KB Output is correct
25 Correct 96 ms 9248 KB Output is correct
26 Correct 83 ms 9300 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 ms 576 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 111 ms 7764 KB Output is correct
35 Correct 103 ms 8452 KB Output is correct
36 Correct 122 ms 9320 KB Output is correct
37 Correct 125 ms 9224 KB Output is correct
38 Correct 99 ms 9120 KB Output is correct
39 Correct 60 ms 5976 KB Output is correct
40 Correct 3 ms 468 KB Output is correct
41 Correct 4 ms 576 KB Output is correct
42 Correct 3 ms 580 KB Output is correct
43 Correct 3 ms 596 KB Output is correct
44 Correct 135 ms 8088 KB Output is correct
45 Correct 140 ms 9380 KB Output is correct
46 Correct 141 ms 9572 KB Output is correct
47 Correct 146 ms 9464 KB Output is correct
48 Correct 116 ms 9392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 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 0 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 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 5 ms 468 KB Output is correct
29 Correct 5 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 3 ms 532 KB Output is correct
32 Correct 3 ms 468 KB Output is correct
33 Correct 4 ms 468 KB Output is correct
34 Correct 7 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
38 Correct 3 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 75 ms 7348 KB Output is correct
51 Correct 53 ms 5768 KB Output is correct
52 Correct 59 ms 7012 KB Output is correct
53 Correct 79 ms 8456 KB Output is correct
54 Correct 72 ms 8484 KB Output is correct
55 Correct 71 ms 8524 KB Output is correct
56 Correct 0 ms 340 KB Output is correct
57 Correct 0 ms 340 KB Output is correct
58 Correct 0 ms 340 KB Output is correct
59 Correct 2 ms 340 KB Output is correct
60 Correct 2 ms 340 KB Output is correct
61 Correct 98 ms 8076 KB Output is correct
62 Correct 80 ms 9068 KB Output is correct
63 Correct 68 ms 7028 KB Output is correct
64 Correct 96 ms 9248 KB Output is correct
65 Correct 83 ms 9300 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 312 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 3 ms 576 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 111 ms 7764 KB Output is correct
74 Correct 103 ms 8452 KB Output is correct
75 Correct 122 ms 9320 KB Output is correct
76 Correct 125 ms 9224 KB Output is correct
77 Correct 99 ms 9120 KB Output is correct
78 Correct 60 ms 5976 KB Output is correct
79 Correct 3 ms 468 KB Output is correct
80 Correct 4 ms 576 KB Output is correct
81 Correct 3 ms 580 KB Output is correct
82 Correct 3 ms 596 KB Output is correct
83 Correct 135 ms 8088 KB Output is correct
84 Correct 140 ms 9380 KB Output is correct
85 Correct 141 ms 9572 KB Output is correct
86 Correct 146 ms 9464 KB Output is correct
87 Correct 116 ms 9392 KB Output is correct
88 Correct 198 ms 8408 KB Output is correct
89 Correct 207 ms 12448 KB Output is correct
90 Correct 196 ms 12436 KB Output is correct
91 Correct 202 ms 12376 KB Output is correct
92 Correct 162 ms 10964 KB Output is correct
93 Correct 167 ms 11300 KB Output is correct
94 Correct 164 ms 11044 KB Output is correct
95 Correct 175 ms 12308 KB Output is correct
96 Correct 197 ms 12620 KB Output is correct
97 Correct 160 ms 12424 KB Output is correct
98 Correct 126 ms 9888 KB Output is correct
99 Correct 131 ms 11188 KB Output is correct