Submission #796352

#TimeUsernameProblemLanguageResultExecution timeMemory
796352vjudge1Team Contest (JOI22_team)C++17
100 / 100
82 ms6280 KiB
#ifdef Home #define _GLIBCXX_DEBUG #endif // Home #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int N = 150150; struct chel{ int x, y, z; }; bitset < N > is_del; main() { #ifdef Home freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // Home ios_base::sync_with_stdio(0); cin.tie(0); int n, m = 0; cin >> n; vector < chel > V(n); vector < pair < int, int > > X(n), Y(n), Z(n); for(auto &[x, y, z] : V) { cin >> x >> y >> z; X[m] = {x, m}; Y[m] = {y, m}; Z[m] = {z, m}; ++ m; } sort(X.begin(), X.end()); sort(Y.begin(), Y.end()); sort(Z.begin(), Z.end()); is_del.reset(); for(int x, y, z;;) { for(; !X.empty() && is_del[X.back().second]; X.pop_back()); for(; !Y.empty() && is_del[Y.back().second]; Y.pop_back()); for(; !Z.empty() && is_del[Z.back().second]; Z.pop_back()); if(X.empty() || Y.empty() || Z.empty()) { break; } x = X.back().second; if(V[x].y == Y.back().first || V[x].z == Z.back().first) { is_del[x] = true; continue; } y = Y.back().second; if(V[y].x == X.back().first || V[y].z == Z.back().first) { is_del[y] = true; continue; } z = Z.back().second; if(V[z].x == X.back().first || V[z].y == Y.back().first) { is_del[z] = true; continue; } cout << X.back().first + Y.back().first + Z.back().first; return 0; } cout << -1; }

Compilation message (stderr)

team.cpp:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...