QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190945#5140. Frozen ScoreboardchroneZWA 0ms3828kbC++173.1kb2023-09-29 16:08:382023-09-29 16:08:38

Judging History

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

  • [2023-09-29 16:08:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3828kb
  • [2023-09-29 16:08:38]
  • 提交

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) {
			if(s == 0) {
				cout << "Yes\n";
				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 {
						cout << "- " << a[j].y << "\n";
					}
				}
				return;
			}
			for(int i = 0; i < p.size(); i++) {
				if(!(s >> i & 1)) continue;
				P -= q[i].l;
			}
			for(int i = 0; i < p.size(); i++) {
				if((!(s >> i & 1)) && s != 0) continue;
				if(P <= q[i].r - q[i].l) {
					cout << "Yes\n";
					int tail = -1;
					int id = p[i];
					int occ = P / 20;
					int d = min(a[id].x - 1, 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 + 1 << "/" << 240 + P << "\n";
							} else if(tail < i) {
								cout << "+ " << a[j].y << "/" << 299 << "\n";
							} else {
								cout << "+ " << a[j].y - a[j].x + 1 << "/" << 240 << "\n";
							}
						}
					}
					return;
				} else {
					P -= q[i].r - q[i].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 
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

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

output:

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

result:

ok ok (1 test case)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3828kb

input:

6 2
1 100
.
? 3 4
2 100
+ 1/1
+ 1/2
0 0
- 5
- 6
2 480
? 100 100
? 100 100
2 480
? 99 100
? 100 100
1 2000
? 100 100
? 100 100

output:

No
No
Yes
- 5
- 6
Yes
+ 1/240
+ 1/240
No
Yes
+ 89/240
+ 1/240

result:

wrong answer wrong number of solved problems (test case 6)