| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1303083 | duyhoanho | Team Contest (JOI22_team) | C++20 | 92 ms | 8792 KiB |
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
const int N = 15e4 + 10;
int n, ban[N];
vector<int> px, py, pz;
struct node{
int x, y, z;
}A[N];
bool cmp1(int a, int b){
return A[a].x < A[b].x;
}
bool cmp2(int a, int b){
return A[a].y < A[b].y;
}
bool cmp3(int a, int b){
return A[a].z < A[b].z;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if(fopen("task.inp", "r")){
freopen("task.inp", "r", stdin);
freopen("task.out", "w", stdout);
}
#define task "teamcontest"
if(fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n;
for(int i = 1; i <= n; i++){
int x, y, z;
cin >> x >> y >> z;
A[i] = {x, y, z};
px.push_back(i);
py.push_back(i);
pz.push_back(i);
}
sort(px.begin(), px.end(), cmp1);
sort(py.begin(), py.end(), cmp2);
sort(pz.begin(), pz.end(), cmp3);
int x = n - 1;
int y = n - 1;
int z = n - 1;
while(x != -1 && y != -1 && z != -1){
int mx = A[px[x]].x;
int my = A[py[y]].y;
int mz = A[pz[z]].z;
int cntx = 1 + (A[px[x]].y == my) + (A[px[x]].z == mz);
int cnty = 1 + (A[py[y]].x == mx) + (A[py[y]].z == mz);
int cntz = 1 + (A[pz[z]].y == my) + (A[pz[z]].x == mx);
if(cntx >= 2){
ban[px[x]] = 1;
x--;
}
else if(cnty >= 2){
ban[py[y]] = 1;
y--;
}
else if(cntz >= 2){
ban[pz[z]] = 1;
z--;
}
else{
cout<<mx+my+mz;
return 0;
}
while(x != -1 && ban[px[x]]) x--;
while(y != -1 && ban[py[y]]) y--;
while(z != -1 && ban[pz[z]]) z--;
}
cout<<-1;
}
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... | ||||
