Submission #119082

# Submission time Handle Problem Language Result Execution time Memory
119082 2019-06-20T09:48:45 Z SOIVIEONE Wall (IOI14_wall) C++14
0 / 100
949 ms 262144 KB
#include <bits/stdc++.h>
#include "wall.h"
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 2222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
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;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
vector<pair<ll, pll> > adl[N], adr[N], reml[N], remr[N];

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
	for(int i = 0; i < k; i ++)
	{
		if(op[i] == 1)
		{
			adl[left[i]].pb(M(height[i], M(i, 1)));
			if(right[i] + 1 < n)
				adr[right[i] + 1].pb(M(height[i], M(i, 1)));
		}
		else
		{
			reml[left[i]].pb(M(height[i], M(i, 2)));
			if(right[i] + 1 < n)
				remr[right[i] + 1].pb(M(height[i], M(i, 2)));
		}
	}
	multiset<pair<ll,pll> > foo, hoo;
	for(int i = 0; i < n; i ++)
	{
		for(auto it : remr[i])
			hoo.erase(hoo.find(it));
		for(auto it : adr[i])
			foo.erase(foo.find(it));
		for(auto it : adl[i])
			foo.insert(it);
		for(auto it : reml[i])
			hoo.insert(it);
		if(foo.empty())
		{
			finalHeight[i] = 0;
			continue;
		}
		auto ii = foo.end(); ii--;
		pair<ll, pll> fo = *ii;
		if(hoo.empty())
		{
			finalHeight[i] = fo.F;
			continue;
		}
		ii = hoo.begin();
		pair<ll, pll> ho = *ii;
		ll res = 0;
		if(fo.S.F < ho.S.F)
		{
			res = fo.F;
			umin(res, ho.F);
		}
		else
		{
			res = fo.F;
		}
		finalHeight[i] = res;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 184 ms 209272 KB Output is correct
2 Incorrect 189 ms 209656 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 188 ms 209144 KB Output is correct
2 Correct 949 ms 262144 KB Output is correct
3 Correct 595 ms 236972 KB Output is correct
4 Runtime error 735 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 183 ms 209152 KB Output is correct
2 Incorrect 182 ms 209656 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 182 ms 209016 KB Output is correct
2 Incorrect 180 ms 209656 KB Output isn't correct
3 Halted 0 ms 0 KB -