# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1096876 | thangdz2k7 | Team Contest (JOI22_team) | C++17 | 109 ms | 12512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// author : thembululquaUwU
// 3.9.2024
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using ar = array <int, 4>;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}
vector <ar> V[3];
bool bad[N];
int n;
#define fr(i) for (int i = 0; i < 3; ++ i)
#define V(x, y) V[x][i[x]][y]
void solve(){
cin >> n; int i[] = {n - 1, n - 1, n - 1};
for (int j = 0; j < n; ++ j){
int x, y, z; cin >> x >> y >> z;
fr(t) V[t].pb({x, y, z, j});
}
fr(t) sort(V[t].begin(), V[t].end(), [&](ar a, ar b) {return a[t] < b[t]; });
while (true){
fr(j) {
while (i[j] >= 0 && bad[(V(j, 3))]) -- i[j];
if (i[j] < 0){
cout << -1;
return;
}
}
ll ans = 0;
vi v; fr(j) v.pb(V(j, 3)), ans += V(j, j); bool ok = 0;
fr(j) fr(t) if ((j ^ t) && V(j, j) == V(t, j)) bad[v[t]] = 1, ok = 1;
if (!ok) {
cout << ans << endl; return;
}
}
}
int main(){
if (fopen("pqh.inp", "r")){
freopen("pqh.inp", "r", stdin);
freopen("pqh.out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t = 1; // cin >> t;
while (t --) solve();
return 0;
}
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... |