답안 #1049902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1049902 2024-08-09T06:00:29 Z fuad27 식물 비교 (IOI20_plants) C++17
14 / 100
4000 ms 10580 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

struct lazy_segtree {
	vector<int> v;
	lazy_segtree(vector<int> &a) {
		v=a;
	}
	void update(int l, int r, int add) {
		for(int i = l;i<=r;i++)v[i]+=add;
	}
	pair<int,int> query(int l, int r){
		if(r < l)return pair{1e9, 1e9};
		pair<int,int> p = {v[l], l};
		for(int i = l;i<=r;i++)p=min(p, pair{v[i], i});
		return p;
	}
};

vector<int> H;

void init(int k, std::vector<int> r) {
	int n = r.size();
	lazy_segtree ls(r);
	int cnt = n;
	H.resize(n, -1);
	auto dfs = [&](int at, auto &&dfs) -> void {
		if(at >= k-1) {
			pair<int,int> val = ls.query(at-k+1, at-1);
			while(val.first == 0) {
				dfs(val.second, dfs);
				val = ls.query(at-k+1, at-1);
			}
			H[at] = cnt--;
			ls.update(at-k+1, at-1, -1);
			ls.update(at, at, 1e9);
		}
		else {
			pair<int,int> val = min(ls.query(0, at-1), ls.query(n-k+at+1, n-1));
			while(val.first == 0) {
				dfs(val.second, dfs);
				val = min(ls.query(0, at-1), ls.query(n-k+at+1, n-1));
			}
			H[at] = cnt--;
			ls.update(0, at-1, -1), ls.update(n-k+at+1, n-1, -1);
			ls.update(at, at, 1e9);
		}
	};
	while(ls.query(0, n-1).first == 0) {
		dfs(ls.query(0, n-1).second, dfs);
	}
	return;
}

int compare_plants(int x, int y) {
	if(H[x] < H[y])return -1;
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 448 KB Output is correct
7 Correct 110 ms 5008 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 103 ms 5100 KB Output is correct
11 Correct 94 ms 5000 KB Output is correct
12 Correct 81 ms 5204 KB Output is correct
13 Correct 113 ms 5456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 448 KB Output is correct
7 Correct 110 ms 5008 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 103 ms 5100 KB Output is correct
11 Correct 94 ms 5000 KB Output is correct
12 Correct 81 ms 5204 KB Output is correct
13 Correct 113 ms 5456 KB Output is correct
14 Correct 1018 ms 5576 KB Output is correct
15 Execution timed out 4022 ms 9552 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 32 ms 4948 KB Output is correct
4 Execution timed out 4080 ms 10580 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -