Submission #1303083

#TimeUsernameProblemLanguageResultExecution timeMemory
1303083duyhoanhoTeam Contest (JOI22_team)C++20
100 / 100
92 ms8792 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)

team.cpp: In function 'int32_t main()':
team.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     freopen("task.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen("task.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     freopen(task".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen(task".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...