Submission #587801

# Submission time Handle Problem Language Result Execution time Memory
587801 2022-07-02T11:37:05 Z Red_Inside Team Contest (JOI22_team) C++17
0 / 100
6 ms 468 KB
//
#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(ban[ind[1][uk[1]]])
		{
			uk[1]++;
		}
		while(ban[ind[2][uk[2]]])
		{
			uk[2]++;
		}
		while(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

team.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 4 ms 468 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 4 ms 468 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 6 ms 436 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 6 ms 436 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 6 ms 436 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 6 ms 436 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 4 ms 468 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -