| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1340431 | dex111222333444555 | Team Contest (JOI22_team) | C++20 | 384 ms | 23340 KiB |
#include <bits/stdc++.h>
#define siz(v) (int)(v).size()
#define ii pair<int, int>
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define dbg(x) "[" #x " = " << x << "]"
#define BIT(x, i) (((x) >> (i)) & 1)
#define lli pair<long long, int>
#define MASK(i) (1LL << (i))
#define left __left
#define right __right
using namespace std;
const int MAXN = 2e5 + 5, infINT = 1e9 + 13213, LOG = 18;
const long long mod = (1LL << 32), inf = 1e18 + 13212;
template<class X, class Y> bool minimize(X &x, const Y &y){return x > y ? x = y, 1: 0;}
template<class X, class Y> bool maximize(X &x, const Y &y){return x < y ? x = y, 1: 0;}
void add(long long &a, const long long &b){
a += b;
if (a >= mod) a -= mod;
}
void sub(long long &a, const long long &b){
a -= b;
if (a < 0) a += mod;
}
long long mul(const long long &a, const long long &b){
return 1LL * a * 1LL * b % mod;
}
int numVal, val[MAXN][3];
set<ii > pos[3];
void input(){
cin >> numVal;
for(int i = 1; i <= numVal; i++){
for(int j = 0; j < 3; j++){
cin >> val[i][j];
}
for(int j = 0; j < 3; j++){
pos[j].insert(ii(val[i][j], i));
}
}
}
void solve(){
int cnt = 0;
while(siz(pos[0]) > 2){
bool flag = 0;
for(int i = 0; i < 3 && siz(pos[0]) > 2; i++){
set<ii>::iterator it = prev(end(pos[i]));
int id = it->se;
for(int j = 0; j < 3 && siz(pos[0]) > 2; j++) if (i != j) {
if (val[id][j] == prev(end(pos[j]))->fi){
it--;
for(int k = 0; k < 3; k++) pos[k].erase(ii(val[id][k], id));
id = it->se;
flag = 1;
}
}
}
if (!flag) break;
}
if (siz(pos[0]) == 2) cout << -1 << '\n';
else{
int res = 0;
for(int i = 0; i < 3; i++){
res += prev(end(pos[i]))->fi;
}
cout << res << '\n';
}
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); ;cout.tie(0);
#define task "test"
if (fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
input();
solve();
cerr << (1.0 * clock()) / CLOCKS_PER_SEC << ".s\n";
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
