답안 #567753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567753 2022-05-24T06:51:36 Z jamezzz Team Contest (JOI22_team) C++17
100 / 100
522 ms 24960 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define dbg(...) printf(__VA_ARGS__);
#define getchar_unlocked getchar
#else
#define dbg(...)
#endif
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define mnto(x,y) x=min(x,(__typeof__(x))y)
#define mxto(x,y) x=max(x,(__typeof__(x))y)
#define INF 1023456789
#define LINF 1023456789123456789
#define all(x) x.begin(), x.end()
#define disc(x) sort(all(x));x.resize(unique(all(x))-x.begin());
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vll;
mt19937 rng(time(0));

#define mod 1000000007

inline int add(int a,int b){
	int r=a+b;
	while(r>=mod)r-=mod;
	while(r<0)r+=mod;
	return r;
}

inline int mult(int a,int b){
	return (int)(((ll)(a*b))%mod);
}

inline int rd(){
	int x=0;
	char ch=getchar_unlocked();
	while(!(ch&16))ch=getchar();//keep reading while current character is whitespace
    while(ch&16){//this will break when ‘\n’ or ‘ ‘ is encountered
		x=(x<<3)+(x<<1)+(ch&15);
		ch=getchar_unlocked();
	}
	return x;
}

#define maxn 150005

set<ii> sx,sy,sz;

int n,x[maxn],y[maxn],z[maxn];

void del(int i){
	sx.erase(sx.find({x[i],i}));
	sy.erase(sy.find({y[i],i}));
	sz.erase(sz.find({z[i],i}));
}

int main(){
	sf("%d",&n);
	for(int i=0;i<n;++i){
		sf("%d%d%d",&x[i],&y[i],&z[i]);
		sx.insert({x[i],i});
		sy.insert({y[i],i});
		sz.insert({z[i],i});
	}
	while(true){
		if(sx.empty()||sy.empty()||sz.empty())pf("-1\n"),exit(0);
		int a=(*--sx.end()).se,b=(*--sy.end()).se,c=(*--sz.end()).se;
		if(y[a]>=y[b]||z[a]>=z[c])del(a);
		else if(x[b]>=x[a]||z[b]>=z[c])del(b);
		else if(x[c]>=x[a]||y[c]>=y[b])del(c);
		else pf("%d\n",x[a]+y[b]+z[c]),exit(0);
	}
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:70:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |  sf("%d",&n);
      |    ^
team.cpp:72:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |   sf("%d%d%d",&x[i],&y[i],&z[i]);
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 4 ms 852 KB Output is correct
27 Correct 4 ms 852 KB Output is correct
28 Correct 4 ms 852 KB Output is correct
29 Correct 5 ms 828 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 4 ms 928 KB Output is correct
32 Correct 5 ms 852 KB Output is correct
33 Correct 4 ms 852 KB Output is correct
34 Correct 4 ms 852 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 816 KB Output is correct
38 Correct 4 ms 852 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
11 Correct 184 ms 23176 KB Output is correct
12 Correct 149 ms 15500 KB Output is correct
13 Correct 126 ms 19136 KB Output is correct
14 Correct 231 ms 23140 KB Output is correct
15 Correct 161 ms 23292 KB Output is correct
16 Correct 171 ms 23244 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
11 Correct 184 ms 23176 KB Output is correct
12 Correct 149 ms 15500 KB Output is correct
13 Correct 126 ms 19136 KB Output is correct
14 Correct 231 ms 23140 KB Output is correct
15 Correct 161 ms 23292 KB Output is correct
16 Correct 171 ms 23244 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 201 ms 23184 KB Output is correct
23 Correct 224 ms 22812 KB Output is correct
24 Correct 193 ms 16868 KB Output is correct
25 Correct 323 ms 23052 KB Output is correct
26 Correct 183 ms 23276 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
11 Correct 184 ms 23176 KB Output is correct
12 Correct 149 ms 15500 KB Output is correct
13 Correct 126 ms 19136 KB Output is correct
14 Correct 231 ms 23140 KB Output is correct
15 Correct 161 ms 23292 KB Output is correct
16 Correct 171 ms 23244 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 201 ms 23184 KB Output is correct
23 Correct 224 ms 22812 KB Output is correct
24 Correct 193 ms 16868 KB Output is correct
25 Correct 323 ms 23052 KB Output is correct
26 Correct 183 ms 23276 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 244 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 242 ms 22108 KB Output is correct
35 Correct 339 ms 20936 KB Output is correct
36 Correct 340 ms 23196 KB Output is correct
37 Correct 427 ms 22976 KB Output is correct
38 Correct 217 ms 22720 KB Output is correct
39 Correct 99 ms 13928 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
11 Correct 184 ms 23176 KB Output is correct
12 Correct 149 ms 15500 KB Output is correct
13 Correct 126 ms 19136 KB Output is correct
14 Correct 231 ms 23140 KB Output is correct
15 Correct 161 ms 23292 KB Output is correct
16 Correct 171 ms 23244 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 201 ms 23184 KB Output is correct
23 Correct 224 ms 22812 KB Output is correct
24 Correct 193 ms 16868 KB Output is correct
25 Correct 323 ms 23052 KB Output is correct
26 Correct 183 ms 23276 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 244 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 242 ms 22108 KB Output is correct
35 Correct 339 ms 20936 KB Output is correct
36 Correct 340 ms 23196 KB Output is correct
37 Correct 427 ms 22976 KB Output is correct
38 Correct 217 ms 22720 KB Output is correct
39 Correct 99 ms 13928 KB Output is correct
40 Correct 3 ms 724 KB Output is correct
41 Correct 4 ms 852 KB Output is correct
42 Correct 5 ms 852 KB Output is correct
43 Correct 6 ms 852 KB Output is correct
44 Correct 378 ms 23248 KB Output is correct
45 Correct 483 ms 24420 KB Output is correct
46 Correct 471 ms 24704 KB Output is correct
47 Correct 522 ms 24876 KB Output is correct
48 Correct 259 ms 24780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 4 ms 852 KB Output is correct
27 Correct 4 ms 852 KB Output is correct
28 Correct 4 ms 852 KB Output is correct
29 Correct 5 ms 828 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 4 ms 928 KB Output is correct
32 Correct 5 ms 852 KB Output is correct
33 Correct 4 ms 852 KB Output is correct
34 Correct 4 ms 852 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 816 KB Output is correct
38 Correct 4 ms 852 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 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 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 1 ms 212 KB Output is correct
50 Correct 184 ms 23176 KB Output is correct
51 Correct 149 ms 15500 KB Output is correct
52 Correct 126 ms 19136 KB Output is correct
53 Correct 231 ms 23140 KB Output is correct
54 Correct 161 ms 23292 KB Output is correct
55 Correct 171 ms 23244 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 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 201 ms 23184 KB Output is correct
62 Correct 224 ms 22812 KB Output is correct
63 Correct 193 ms 16868 KB Output is correct
64 Correct 323 ms 23052 KB Output is correct
65 Correct 183 ms 23276 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 244 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 5 ms 852 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 468 KB Output is correct
73 Correct 242 ms 22108 KB Output is correct
74 Correct 339 ms 20936 KB Output is correct
75 Correct 340 ms 23196 KB Output is correct
76 Correct 427 ms 22976 KB Output is correct
77 Correct 217 ms 22720 KB Output is correct
78 Correct 99 ms 13928 KB Output is correct
79 Correct 3 ms 724 KB Output is correct
80 Correct 4 ms 852 KB Output is correct
81 Correct 5 ms 852 KB Output is correct
82 Correct 6 ms 852 KB Output is correct
83 Correct 378 ms 23248 KB Output is correct
84 Correct 483 ms 24420 KB Output is correct
85 Correct 471 ms 24704 KB Output is correct
86 Correct 522 ms 24876 KB Output is correct
87 Correct 259 ms 24780 KB Output is correct
88 Correct 396 ms 24928 KB Output is correct
89 Correct 438 ms 24808 KB Output is correct
90 Correct 383 ms 24876 KB Output is correct
91 Correct 436 ms 24716 KB Output is correct
92 Correct 382 ms 24960 KB Output is correct
93 Correct 421 ms 24872 KB Output is correct
94 Correct 438 ms 24868 KB Output is correct
95 Correct 260 ms 24896 KB Output is correct
96 Correct 231 ms 24908 KB Output is correct
97 Correct 175 ms 24936 KB Output is correct
98 Correct 139 ms 24876 KB Output is correct
99 Correct 173 ms 24888 KB Output is correct