Submission #1083104

# Submission time Handle Problem Language Result Execution time Memory
1083104 2024-09-02T14:31:58 Z n1k Wall (IOI14_wall) C++17
8 / 100
3000 ms 33540 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	vector<array<int, 3>> v;
	for(int i=0; i<k; i++){
		v.push_back({left[i], i, 0});
		v.push_back({right[i]+1, i, 1});
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	vector<int> hu(k, -1), ho(k, -1);
	for(int i=0; i<n; i++){
		while(v.size() and v.back()[0]<=i){
			auto [b, id, tp]=v.back();
			v.pop_back();
			if(tp==0){
				if(op[id]==1){
					hu[id]=height[id];
				}else{
					ho[id]=height[id];
				}
			}else{
				if(op[id]==1){
					hu[id]=-1;
				}else{
					ho[id]=-1;
				} 
			}
		}
		int o = 1e9, u = -1;
		bool bd = 1;
		for(int j=k-1; j>=0; j--){
			if(hu[j]!=-1){
				u = max(u, hu[j]);
			}if(ho[j]!=-1){
				o = min(o, ho[j]);
			}
			// >= ?
			if(u>o){
				if(u==hu[j]){
					finalHeight[i]=o;
					bd=0;
					break;
				}else if(o==ho[j]){
					finalHeight[i]=u;
					bd=0;
					break;
				}else{
					while(1);
				}
			}
		}
		if(bd){
			finalHeight[i]=max(0, u);
		}
	}
	return;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 46 ms 888 KB Output is correct
6 Correct 46 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 213 ms 29496 KB Output is correct
3 Correct 1233 ms 14004 KB Output is correct
4 Execution timed out 3059 ms 33532 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 54 ms 752 KB Output is correct
6 Correct 46 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 176 ms 29512 KB Output is correct
9 Correct 1253 ms 14008 KB Output is correct
10 Execution timed out 3045 ms 33540 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 46 ms 860 KB Output is correct
6 Correct 51 ms 856 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 171 ms 29608 KB Output is correct
9 Correct 1226 ms 13888 KB Output is correct
10 Execution timed out 3033 ms 33448 KB Time limit exceeded
11 Halted 0 ms 0 KB -