# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
768400 | nguyentunglam | Team Contest (JOI22_team) | C++17 | 481 ms | 62876 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 2e5 + 10;
int x[N], y[N], z[N];
map<pair<int, int>, vector<int> > m[3];
bool ban[N];
int X, Y, Z;
vector<ii> vx, vy, vz;
int main() {
#define task ""
cin.tie(0) -> sync_with_stdio(0);
if (fopen ("task.inp", "r")) {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
}
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int n; cin >> n;
for(int i = 1; i <= n; i++) {
cin >> x[i] >> y[i] >> z[i];
vx.emplace_back(x[i], i);
vy.emplace_back(y[i], i);
vz.emplace_back(z[i], i);
m[0][{x[i], y[i]}].push_back(i);
m[1][{y[i], z[i]}].push_back(i);
m[2][{x[i], z[i]}].push_back(i);
}
sort(vx.begin(), vx.end());
sort(vy.begin(), vy.end());
sort(vz.begin(), vz.end());
int cur = n;
while (cur >= 3) {
while (ban[vx.back().se]) vx.pop_back();
while (ban[vy.back().se]) vy.pop_back();
while (ban[vz.back().se]) vz.pop_back();
if (vx.empty() || vy.empty() || vz.empty()) break;
X = vx.back().first;
Y = vy.back().first;
Z = vz.back().first;
int pre = cur;
for(int &j : m[0][{X, Y}]) if (ban[j] == 0) {
cur--; ban[j] = 1;
}
for(int &j : m[1][{Y, Z}]) if (ban[j] == 0) {
cur--; ban[j] = 1;
}
for(int &j : m[2][{X, Z}]) if (ban[j] == 0) {
cur--; ban[j] = 1;
}
m[0][{X, Y}].clear();
m[1][{Y, Z}].clear();
m[2][{X, Z}].clear();
if (pre == cur) return cout << X + Y + Z, 0;
}
cout << -1;
}
컴파일 시 표준 에러 (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... |