Submission #587804

#TimeUsernameProblemLanguageResultExecution timeMemory
587804Red_InsideTeam Contest (JOI22_team)C++17
100 / 100
207 ms12620 KiB
// #include <bits/stdc++.h> #define ll long long #define f first #define s second #define pb push_back #define mp make_pair #define o cout<<"BUG"<<endl; #define FOR(i, j, n) for(int j = i; j < n; ++j) #define forn(i, j, n) for(int j = i; j <= n; ++j) #define nfor(i, j, n) for(int j = n; j >= i; --j) #define sortv(vv) sort(vv.begin(), vv.end()) #define all(v) v.begin(), v.end() #define ld long double #define ull unsigned long long using namespace std; const int maxn=3e5+10,LOG=17, mod=1e9+7; int block = 320, timer = 0; const ld EPS = 1e-18; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define bt(i) (1 << (i)) #define int ll const int inf=2e18; #define y1 yy #define prev pre #define pii pair <int, int> int n, a[maxn], b[maxn], c[maxn], uk[5], ind[5][maxn], ban[maxn]; bool cmp1(int i, int j) { return a[i] > a[j]; } bool cmp2(int i, int j) { return b[i] > b[j]; } bool cmp3(int i, int j) { return c[i] > c[j]; } main() { cin >> n; forn(1, i, n) { cin >> a[i] >> b[i] >> c[i]; ind[1][i] = i; ind[2][i] = i; ind[3][i] = i; } sort(ind[1] + 1, ind[1] + 1 + n, cmp1); sort(ind[2] + 1, ind[2] + 1 + n, cmp2); sort(ind[3] + 1, ind[3] + 1 + n, cmp3); while(true) { while(uk[1] <= n && ban[ind[1][uk[1]]]) { uk[1]++; } while(uk[2] <= n && ban[ind[2][uk[2]]]) { uk[2]++; } while(uk[3] <= n && ban[ind[3][uk[3]]]) { uk[3]++; } if(uk[1] > n || uk[2] > n || uk[3] > n) { cout << -1; return 0; } if(b[ind[1][uk[1]]] == b[ind[2][uk[2]]] || c[ind[1][uk[1]]] == c[ind[3][uk[3]]]) { ban[ind[1][uk[1]]] = 1; continue; } if(a[ind[2][uk[2]]] == a[ind[1][uk[1]]] || c[ind[2][uk[2]]] == c[ind[3][uk[3]]]) { ban[ind[2][uk[2]]] = 1; continue; } if(a[ind[3][uk[3]]] == a[ind[1][uk[1]]] || b[ind[3][uk[3]]] == b[ind[2][uk[2]]]) { ban[ind[3][uk[3]]] = 1; continue; } cout << a[ind[1][uk[1]]] + b[ind[2][uk[2]]] + c[ind[3][uk[3]]]; return 0; } }

Compilation message (stderr)

team.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | 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...