QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#129166#6742. LeavesjeffqiRE 1ms3536kbC++232.0kb2023-07-22 03:54:142023-07-22 03:54:18

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-22 03:54:18]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3536kb
  • [2023-07-22 03:54:14]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define eb emplace_back
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define ull unsigned ll
#define i128 __int128
using namespace std;
namespace qiqi {
	void main() {
		int n,m;
		cin >> n >> m;
		vi a(n); vector<array<int,2>> ch(n,{-1,-1});
		for (int i = 0; i < n; i++) {
			int c; cin >> c;
			if (c == 1) {
				for (int j = 0; j < 2; j++) {
					cin >> ch[i][j]; ch[i][j]--;
				}
			}
			else {
				cin >> a[i];
			}
		}
		auto dfs = [&](auto self,int u) -> vector<vi> {
			vector<vi> vec(m+1);
			if (ch[u] == array<int,2>{-1,-1}) {
				for (int i = 0; i <= m; i += 2) {
					vec[i] = vi({a[u]});
				}
			}
			else {
				vector<vi> v[2];
				for (int i = 0; i < 2; i++) {
					v[i] = self(self,ch[u][i]);
				}
				for (int j = 0; j < 2; j++) {
					for (int k = 0,p = 0; k < 2; k++,p++) {
						for (int i = k; i+j <= m; i++) {
							if (!v[j][p].empty() && !v[j^1][i-p].empty()) {
								int cur = (i-k)/2*2+k;
								if (v[j][cur] < v[j][p]) {
									p = cur;
								}
								vi tmp = v[j][p];
								for (auto x:v[j^1][i-p]) {
									tmp.eb(x);
								}
								if (vec[i+j].empty()) {
									vec[i+j] = tmp;
								}
								else {
									vec[i+j] = min(vec[i+j],tmp);
								}
							}
						}
					}
				}
			}
			return vec;
		};
		auto vec = dfs(dfs,0)[m];
		for (auto x:vec) {
			cout << x << ' ';
		}
		cout << '\n';
	}
}
int main() {
//	clock_t st = clock();
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	qiqi::main();
//	cout << (double)(clock()-st)/CLOCKS_PER_SEC;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3532kb

input:

3 0
1 2 3
2 1
2 2

output:

1 2 

result:

ok 2 number(s): "1 2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3496kb

input:

7 1
1 2 3
1 4 5
1 6 7
2 4
2 2
2 3
2 1

output:

2 4 3 1 

result:

ok 4 number(s): "2 4 3 1"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

7 2
1 2 3
1 4 5
1 6 7
2 4
2 2
2 3
2 1

output:

1 3 4 2 

result:

ok 4 number(s): "1 3 4 2"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3432kb

input:

1 0
2 1000000000

output:

1000000000 

result:

ok 1 number(s): "1000000000"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

3 1
1 2 3
2 1
2 2

output:

2 1 

result:

ok 2 number(s): "2 1"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

7 2
1 2 3
1 4 5
1 6 7
2 1
2 2
2 3
2 4

output:

1 2 3 4 

result:

ok 4 number(s): "1 2 3 4"

Test #7:

score: -100
Runtime Error

input:

999 480
1 3 2
1 4 5
1 6 7
1 9 8
1 10 11
1 13 12
1 14 15
1 16 17
1 19 18
1 21 20
1 23 22
1 25 24
1 27 26
1 28 29
1 30 31
1 33 32
1 35 34
1 37 36
1 38 39
1 41 40
1 42 43
1 45 44
1 46 47
1 48 49
1 51 50
1 52 53
1 55 54
1 56 57
1 58 59
1 61 60
1 62 63
1 64 65
1 67 66
1 69 68
1 71 70
1 73 72
1 74 75
1 76...

output:


result: