QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190926#5140. Frozen ScoreboardchroneZWA 0ms3528kbC++172.7kb2023-09-29 15:56:142023-09-29 15:56:14

Judging History

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

  • [2023-09-29 15:56:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3528kb
  • [2023-09-29 15:56:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

struct Query {string op; int x, y;};
pair<int, int> val(string t) {
	int x = 0, y = 0, cur = 0;
	for(int i = 0; i < t.size(); i++) {
		if(t[i] == '/') {
			cur = 1;
			continue;
		}
		if(cur == 0) {
			x = x * 10 + (t[i] ^ 48);
		} else {
			y = y * 10 + (t[i] ^ 48);
		}
	}
	return {x, y};
}
struct Range {
	int l, r;
	inline friend Range operator + (Range x, Range y) {
		return {x.l + y.l, x.r + y.r};
	}
};

void solve(int m) {
	int T, P; cin >> T >> P;
	vector<Query> a(m);
	vector<int> p; vector<Range> q; 
	for(int i = 0; i < m; i++) {
		auto &[op, x, y] = a[i];
		cin >> op;
		if(op == "+") {
			string t; cin >> t;
			auto [v1, v2] = val(t);
			x = v1, y = v2;
			T--, P -= y + (x - 1) * 20;
		}
		if(op == "-") {
			cin >> x;
		}
		if(op == "?") {
			cin >> x >> y;
			p.push_back(i);
			q.push_back({(y - x) * 20 + 240, (y - 1) * 20 + 299});
		}
		if(op == ".") {
			continue;
		}
	}
	if(T < 0 || P < 0) {
		cout << "No\n";
		return;
	}
	for(int s = 0; s < (1 << p.size()); s++) {
		if(__builtin_popcount(s) != T) {
			continue;
		}
		Range t = {0, 0};
		for(int i = 0; i < p.size(); i++) {
			if(!(s >> i & 1)) continue;
			t = t + q[i];
		}
		if(t.l <= P && P <= t.r) {
			for(int i = 0; i < p.size(); i++) {
				if(!(s >> i & 1)) continue;
				P -= t.l;
			}
			for(int i = 0; i < p.size(); i++) {
				if(!(s >> i & 1)) continue;
				if(P <= t.r - t.l) {
					cout << "Yes\n";
					int tail = -1;
					int id = p[i];
					int occ = P / 20;
					int d = min(a[id].x, occ);
					P -= d * 20;
					for(int j = 0; j < m; j++) {
						if(a[j].op != "?") {
							if(a[j].op == "+") {
								cout << a[j].op << " " << a[j].x << "/" << a[j].y << "\n";
							}
							if(a[j].op == "-") {
								cout << a[j].op << " " << a[j].x << "\n";
							}
							if(a[j].op == ".") {
								cout << a[j].op << "\n";
							}
						} else {
							tail++;
							if(!(s >> i & 1)) {
								cout << "- " << a[j].y << "\n";
								continue;
							}
							if(tail == i) {
								cout << "+ " << a[j].y - a[j].x + d << "/" << 240 + P << "\n";
							} else if(tail < i) {
								cout << "+ " << a[j].y << "/" << 299 << "\n";
							} else {
								cout << "+ " << a[j].x << "/" << 240 << "\n";
							}
						}
					}
					return;
				} else {
					P -= t.r - t.l;
				}
			}
		}
	}
	cout << "No\n";
}

int main() {
	ios::sync_with_stdio(false); 
	cin.tie(nullptr); cout.tie(nullptr);
	
	int n, m; cin >> n >> m;
	while(n--) {
		solve(m);
	}
}
/*
Author: chroneZ
Start thinking at 
Start coding at 
Finish debugging at 
*/

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3528kb

input:

1 13
7 951
+ 1/6
? 3 4
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.

output:

Yes
+ 1/6
+ 2/243
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.

result:

wrong answer wrong total time (test case 1)