Submission #351966

# Submission time Handle Problem Language Result Execution time Memory
351966 2021-01-20T10:11:01 Z Kerim Shortcut (IOI16_shortcut) C++17
0 / 100
1 ms 364 KB
#include "shortcut.h"
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<ll,ll> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const ll B=1e18;
vector<ll>x;
vector<int>d;
int n;
ll C;
vector<pair<PII,PII> >v;
multiset<ll>a,b;
bool ok(ll k){
	v.clear();a.clear();b.clear();	
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++){
			if(d[i]+d[j]+x[j]-x[i]<=k)
				continue;
			ll val=k-d[i]-d[j]-C;
			if(val<0)return 0;
			ll xx=x[i]+x[j],yy=x[j]-x[i];
			v.pb(mp(mp(xx-val,0),mp(yy-val,yy+val)));
			v.pb(mp(mp(xx+val,1),mp(yy-val,yy+val)));
		}
	sort(all(v));int sz=int(v.size());
	if(!sz)return 1;
	for(int i=0;i<sz;i++){
		//cout<<v[i].ff.ff<<" "<<v[i].ff.ss<<" "<<v[i].ss.ff<<" "<<v[i].ss.ss<<endl;
		if(!v[i].ff.ss)
			a.insert(v[i].ss.ff),b.insert(v[i].ss.ss);
		else
			a.erase(a.find(v[i].ss.ff)),b.erase(b.find(v[i].ss.ss));
		if(a.size()==sz/2 and *a.rbegin()<=*b.begin())
			return 1;
	}
	return 0;
}
long long find_shortcut(int N,vector<int> l,vector<int>D, int c){
	d=D;C=c;n=N;x.resize(n);for(int i=0;i<n;i++)x[i]=0;
	for(int i=0;i<n-1;i++)
		x[i+1]=x[i]+l[i];
	ll st=0,en=ll(1e10);
	while(st+1<en){
		ll mid=(st+en)>>1;
		if(ok(mid))
			en=mid;
		else
			st=mid;
	}
	if(ok(st))return st;
	return en;
}

Compilation message

shortcut.cpp: In function 'bool ok(ll)':
shortcut.cpp:48:14: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |   if(a.size()==sz/2 and *a.rbegin()<=*b.begin())
      |      ~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB n = 4, 80 is a correct answer
2 Correct 1 ms 364 KB n = 9, 110 is a correct answer
3 Correct 1 ms 364 KB n = 4, 21 is a correct answer
4 Correct 1 ms 364 KB n = 3, 4 is a correct answer
5 Correct 1 ms 364 KB n = 2, 62 is a correct answer
6 Correct 1 ms 364 KB n = 2, 3 is a correct answer
7 Correct 1 ms 364 KB n = 3, 29 is a correct answer
8 Correct 0 ms 364 KB n = 2, 3 is a correct answer
9 Correct 0 ms 364 KB n = 2, 3 is a correct answer
10 Correct 0 ms 364 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 364 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 364 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 364 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 364 KB n = 4, 3000000001 is a correct answer
15 Correct 1 ms 364 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 364 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 364 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB n = 4, 80 is a correct answer
2 Correct 1 ms 364 KB n = 9, 110 is a correct answer
3 Correct 1 ms 364 KB n = 4, 21 is a correct answer
4 Correct 1 ms 364 KB n = 3, 4 is a correct answer
5 Correct 1 ms 364 KB n = 2, 62 is a correct answer
6 Correct 1 ms 364 KB n = 2, 3 is a correct answer
7 Correct 1 ms 364 KB n = 3, 29 is a correct answer
8 Correct 0 ms 364 KB n = 2, 3 is a correct answer
9 Correct 0 ms 364 KB n = 2, 3 is a correct answer
10 Correct 0 ms 364 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 364 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 364 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 364 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 364 KB n = 4, 3000000001 is a correct answer
15 Correct 1 ms 364 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 364 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 364 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB n = 4, 80 is a correct answer
2 Correct 1 ms 364 KB n = 9, 110 is a correct answer
3 Correct 1 ms 364 KB n = 4, 21 is a correct answer
4 Correct 1 ms 364 KB n = 3, 4 is a correct answer
5 Correct 1 ms 364 KB n = 2, 62 is a correct answer
6 Correct 1 ms 364 KB n = 2, 3 is a correct answer
7 Correct 1 ms 364 KB n = 3, 29 is a correct answer
8 Correct 0 ms 364 KB n = 2, 3 is a correct answer
9 Correct 0 ms 364 KB n = 2, 3 is a correct answer
10 Correct 0 ms 364 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 364 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 364 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 364 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 364 KB n = 4, 3000000001 is a correct answer
15 Correct 1 ms 364 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 364 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 364 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB n = 4, 80 is a correct answer
2 Correct 1 ms 364 KB n = 9, 110 is a correct answer
3 Correct 1 ms 364 KB n = 4, 21 is a correct answer
4 Correct 1 ms 364 KB n = 3, 4 is a correct answer
5 Correct 1 ms 364 KB n = 2, 62 is a correct answer
6 Correct 1 ms 364 KB n = 2, 3 is a correct answer
7 Correct 1 ms 364 KB n = 3, 29 is a correct answer
8 Correct 0 ms 364 KB n = 2, 3 is a correct answer
9 Correct 0 ms 364 KB n = 2, 3 is a correct answer
10 Correct 0 ms 364 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 364 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 364 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 364 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 364 KB n = 4, 3000000001 is a correct answer
15 Correct 1 ms 364 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 364 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 364 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB n = 4, 80 is a correct answer
2 Correct 1 ms 364 KB n = 9, 110 is a correct answer
3 Correct 1 ms 364 KB n = 4, 21 is a correct answer
4 Correct 1 ms 364 KB n = 3, 4 is a correct answer
5 Correct 1 ms 364 KB n = 2, 62 is a correct answer
6 Correct 1 ms 364 KB n = 2, 3 is a correct answer
7 Correct 1 ms 364 KB n = 3, 29 is a correct answer
8 Correct 0 ms 364 KB n = 2, 3 is a correct answer
9 Correct 0 ms 364 KB n = 2, 3 is a correct answer
10 Correct 0 ms 364 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 364 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 364 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 364 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 364 KB n = 4, 3000000001 is a correct answer
15 Correct 1 ms 364 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 364 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 364 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB n = 4, 80 is a correct answer
2 Correct 1 ms 364 KB n = 9, 110 is a correct answer
3 Correct 1 ms 364 KB n = 4, 21 is a correct answer
4 Correct 1 ms 364 KB n = 3, 4 is a correct answer
5 Correct 1 ms 364 KB n = 2, 62 is a correct answer
6 Correct 1 ms 364 KB n = 2, 3 is a correct answer
7 Correct 1 ms 364 KB n = 3, 29 is a correct answer
8 Correct 0 ms 364 KB n = 2, 3 is a correct answer
9 Correct 0 ms 364 KB n = 2, 3 is a correct answer
10 Correct 0 ms 364 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 364 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 364 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 364 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 364 KB n = 4, 3000000001 is a correct answer
15 Correct 1 ms 364 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 364 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 364 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB n = 4, 80 is a correct answer
2 Correct 1 ms 364 KB n = 9, 110 is a correct answer
3 Correct 1 ms 364 KB n = 4, 21 is a correct answer
4 Correct 1 ms 364 KB n = 3, 4 is a correct answer
5 Correct 1 ms 364 KB n = 2, 62 is a correct answer
6 Correct 1 ms 364 KB n = 2, 3 is a correct answer
7 Correct 1 ms 364 KB n = 3, 29 is a correct answer
8 Correct 0 ms 364 KB n = 2, 3 is a correct answer
9 Correct 0 ms 364 KB n = 2, 3 is a correct answer
10 Correct 0 ms 364 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 364 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 364 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 364 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 364 KB n = 4, 3000000001 is a correct answer
15 Correct 1 ms 364 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 364 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 364 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB n = 4, 80 is a correct answer
2 Correct 1 ms 364 KB n = 9, 110 is a correct answer
3 Correct 1 ms 364 KB n = 4, 21 is a correct answer
4 Correct 1 ms 364 KB n = 3, 4 is a correct answer
5 Correct 1 ms 364 KB n = 2, 62 is a correct answer
6 Correct 1 ms 364 KB n = 2, 3 is a correct answer
7 Correct 1 ms 364 KB n = 3, 29 is a correct answer
8 Correct 0 ms 364 KB n = 2, 3 is a correct answer
9 Correct 0 ms 364 KB n = 2, 3 is a correct answer
10 Correct 0 ms 364 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 364 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 364 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 364 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 364 KB n = 4, 3000000001 is a correct answer
15 Correct 1 ms 364 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 364 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 364 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000317
18 Halted 0 ms 0 KB -