QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#778588#5140. Frozen ScoreboardBicycle_23#WA 2ms4264kbC++202.9kb2024-11-24 15:21:112024-11-24 15:21:11

Judging History

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

  • [2024-11-24 15:21:11]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:4264kb
  • [2024-11-24 15:21:11]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<vector>
using namespace std;
#define int long long
#define endl '\n'
typedef pair<int, int> pii;
const int N = 1e3 + 10;
const int mod = 998244353;
int n, m;
string s[N][15];
int a[N][15][2];
struct P
{
	int id, x, y;
};
bool cmp(P a, P b)
{
	return a.x < b.x;
}
vector<P>fp;
int str2int(string s)
{
	int res = 0;
	for (auto c : s)
	{
		res = res * 10 + (c - '0');
	}
	return res;
}
void solve()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int cnt, pnt;
		fp.clear();
		cin >> cnt >> pnt;
		for (int j = 1; j <= m; j++)
		{
			cin >> s[i][j];
			if (s[i][j] == "+")
			{
				string tmp;
				cin >> tmp;
				string x;
				string y;
				int flag = 0;
				for (auto c : tmp)
				{
					if (c == '/')
					{
						flag = 1;
						continue;
					}
					if (flag) y += c;
					else x += c;
				}
				a[i][j][0] = str2int(x);
				a[i][j][1] = str2int(y);
				pnt -= a[i][j][1] + 20 * (a[i][j][0] - 1);
				cnt--;
			}
			else if (s[i][j] == "?")
			{
				string x;
				string y;
				cin >> x >> y;
				a[i][j][0] = str2int(x);
				a[i][j][1] = str2int(y);
			}
			else if (s[i][j] == "-")
			{
				cin >> a[i][j][1];
			}
		}
		pnt -= cnt * 240;
		if (pnt < 0)
		{
			cout << "No" << endl;
			continue;
		}
		int cntf = 0;

		for (int j = 1; j <= m; j++)
		{
			if (s[i][j] == "?")
			{
				cntf++;
				fp.push_back({ j,a[i][j][0],a[i][j][1] });
			}
		}
		sort(fp.begin(), fp.end(), cmp);
		if (cntf < cnt)
		{
			cout << "No" << endl;
			continue;
		}
		else
		{
			for (int j = 0; j < fp.size(); j++)
			{
				int tt = pnt / 20;
				if (cnt == 0) break;
				if (tt == 0 && fp[j].x != fp[j].y)
				{
					pnt = -1;
					cout << "No" << endl;
					break;
				}
				int sc = 240 + tt*20 + pnt % 20;
				if (tt <= fp[j].y)
				{
					s[i][fp[j].id] = "+";
					a[i][fp[j].id][0] = (tt==0?1:tt);
					a[i][fp[j].id][1] = 240 + (tt == 0 ? 0 : 1) * 20 + pnt % 20;
					pnt = 0;
					cnt--;
				}
				else
				{
					s[i][fp[j].id] = "+";
					a[i][fp[j].id][0] = fp[j].y;
					sc = 240 + fp[j].y * 20;
					int tmp = pnt - sc;
					tmp = min(tmp, 59ll);
					a[i][fp[j].id][1] = sc - fp[j].y * 20 + tmp;
					pnt -= fp[j].y * 20 + tmp;
					cnt--;
				}
			}
		}
		if ((pnt != 0 || cnt != 0)&&pnt!=-1)
		{
			cout << "No" << endl;
			continue;
		}
		else if (pnt != -1)
		{
			cout << "Yes" << endl;
			for (int j = 1; j <= m; j++)
			{
				if (s[i][j] == "+")
				{
					cout << "+ " << a[i][j][0] << "/" << a[i][j][1] << endl;
				}
				else if (s[i][j] == "?" || s[i][j] == "-")
				{
					cout << "- " << a[i][j][1] << endl;
				}
				else cout << "." << endl;
			}
		}
		
	}
	
	
}
signed main()
{
	std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin >> T;
	while (T--)
	{
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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/263
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.

result:

ok ok (1 test case)

Test #2:

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

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
+ 88/260
- 100

result:

ok ok (6 test cases)

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 4204kb

input:

1000 13
6 1519
+ 3/183
- 1
+ 9/133
? 2 3
- 5
? 1 3
- 5
? 1 1
? 1 3
- 5
+ 1/165
- 6
? 2 5
2 570
- 2
- 9
.
- 1
- 7
- 6
+ 4/179
- 2
? 2 5
.
- 2
? 1 3
.
1 140
.
- 2
.
- 2
- 1
- 2
- 2
.
.
.
.
+ 3/100
.
1 195
+ 1/195
.
.
.
.
.
.
.
.
? 1 1
.
.
.
0 0
.
.
.
.
.
.
.
.
.
.
.
.
.
3 776
? 8 22
? 1 8
- 6
+ 1/173
...

output:

No
No
Yes
.
- 2
.
- 2
- 1
- 2
- 2
.
.
.
.
+ 3/100
.
Yes
+ 1/195
.
.
.
.
.
.
.
.
- 1
.
.
.
Yes
.
.
.
.
.
.
.
.
.
.
.
.
.
Yes
- 22
+ 5/274
- 6
+ 1/173
- 11
- 9
- 3
- 6
- 6
- 8
- 12
- 1
+ 2/229
No
Yes
.
- 1
.
+ 5/277
- 7
- 2
+ 1/240
- 9
+ 3/213
- 7
+ 1/202
- 1
- 7
Yes
- 23
.
- 3
- 6
- 10
- 2
- 8
- 10
-...

result:

wrong answer ans finds the answer, but out doesn't (test case 1)