QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780926#5140. Frozen ScoreboardBicycle_23WA 603ms4336kbC++204.0kb2024-11-25 14:03:512024-11-25 14:03:51

Judging History

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

  • [2024-11-25 14:03:51]
  • 评测
  • 测评结果:WA
  • 用时:603ms
  • 内存:4336kb
  • [2024-11-25 14:03:51]
  • 提交

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;
}
int cnt, pnt;
int dfs(int idx,int u)
{
	
	if (u == fp.size())
	{
		if (cnt != 0) return 0;
		for (int i = 0; i < u; i++)
		{
			if (s[idx][fp[i].id] == "!")
			{
				a[idx][fp[i].id][1] = 240 + min(59ll, pnt);
				pnt -= min(59ll, pnt);
			}
		}
		if (pnt != 0) return 0;
		return 1;
	}
	if (pnt - 20 * (fp[u].y - fp[u].x) < 0||cnt==0) return dfs(idx, u + 1);
	for (int i = 0; i <= fp[u].x; i++)
	{
		if (i)
		{
			int t = pnt;
			pnt -= 20 * (fp[u].y - fp[u].x + i-1);
			if (pnt < 0)
			{
				pnt = t;
				break;
			}
			cnt--;
			s[idx][fp[u].id] = "!";
			a[idx][fp[u].id][0] = i + fp[u].y - fp[u].x;
			if (dfs(idx, u + 1)) return 1;
			a[idx][fp[u].id][0] = fp[u].x;
			a[idx][fp[u].id][0] = fp[u].y;
			s[idx][fp[u].id] = "?";
			cnt++;
			pnt = t;
		}
		if (dfs(idx, u + 1)) return 1;
	}
	return 0;
}
void solve()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		if (i == 15)
		{
			cin >> cnt >> pnt;
			cout << cnt << "!" << pnt;
			for (int j = 1; j <= m; j++)
			{
				cin >> s[i][j];
				cout << s[i][j];
				if (s[i][j] == "+")
				{
					string tmp;
					cin >> tmp;
					cout << 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;
					cout << x << "!" << y;
					a[i][j][0] = str2int(x);
					a[i][j][1] = str2int(y);
				}
				else if (s[i][j] == "-")
				{
					cin >> a[i][j][1];
					cout << a[i][j][1];
				}
			}
		}
		else
		{
			pnt = cnt = 0;
			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];
				}
			}
			if (pnt - 240 * cnt < 0)
			{
				cout << "No" << endl;
				continue;
			}
			pnt -= 240 * cnt;
			for (int j = 1; j <= m; j++)
			{
				if (s[i][j] == "?")
				{
					int tmp = pnt - 20 * (a[i][j][1] - a[i][j][0]);
					if (tmp >= 0)
					{
						fp.push_back({ j,a[i][j][0],a[i][j][1] });
					}
				}
			}
			if (fp.size() < cnt)
			{
				cout << "No" << endl;
				continue;
			}
			if (dfs(i, 0))
			{
				cout << "Yes" << endl;
				for (int j = 1; j <= m; j++)
				{
					if (s[i][j] == "+" || 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;
				}
			}
			else
			{
				cout << "No" << 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: 4072kb

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: 4104kb

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
- 100
+ 87/280

result:

ok ok (6 test cases)

Test #3:

score: -100
Wrong Answer
time: 603ms
memory: 4336kb

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:

Yes
+ 3/183
- 1
+ 9/133
- 3
- 5
- 3
- 5
+ 1/258
+ 3/240
- 5
+ 1/165
- 6
+ 4/240
Yes
- 2
- 9
.
- 1
- 7
- 6
+ 4/179
- 2
- 5
.
- 2
+ 3/291
.
Yes
.
- 2
.
- 2
- 1
- 2
- 2
.
.
.
.
+ 3/100
.
Yes
+ 1/195
.
.
.
.
.
.
.
.
- 1
.
.
.
Yes
.
.
.
.
.
.
.
.
.
.
.
.
.
Yes
- 22
- 8
- 6
+ 1/173
- 11
- 9
- 3
- 6
+ 4/29...

result:

wrong answer Token parameter [name=yesno] equals to "6!2193+3/206?6!31?3!7-13+5/189?8!27-5?4!8?1!1.+17/104+1/125-2Yes", doesn't correspond to pattern "Yes|No" (test case 15)