QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#560489#3588. Hamilton - The MusicalYarema#WA 0ms3588kbC++201.3kb2024-09-12 15:56:412024-09-12 15:56:41

Judging History

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

  • [2024-09-12 15:56:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-09-12 15:56:41]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;

const int LOG = 33;
const string days[7] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};

int f[LOG][5];
LL w[LOG][5];

void init()
{
	FOR(i, 0, 5)
	{
		int t = 30;
		while ((i + t) % 7 >= 5)
			t++;
		f[0][i] = (i + t) % 7;
		w[0][i] = t;
	}
	FOR(j, 1, LOG)
	{
		FOR(i, 0, 5)
		{
			int k = f[j - 1][i];
			f[j][i] = f[j - 1][k];
			w[j][i] = w[j - 1][i] + w[j - 1][k];
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	init();
	string s;
	int n;
	cin >> s >> n;
	int today = find(days, days + 7, s) - days;
	LL ans = 47;
	while (n--)
	{
		int d;
		cin >> d;
		int v = ((today - d) % 7 + 7) % 7;
		assert(0 <= v && v < 5);
		LL sum = 0;
		RFOR(i, LOG, 0)
		{
			if (sum + w[i][v] < d)
			{
				sum += w[i][v];
				v = f[i][v];
			}
		}
		if (sum < d)
		{
			sum += w[0][v];
		}
		ans = min(ans, sum - d);
	}
	cout << ans << "\n";
	return 0;
}

詳細信息

Test #1:

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

input:

4
0 3 2 13
3 0 8 9
2 8 0 5
13 9 5 0

output:

47

result:

wrong answer 1st lines differ - expected: '16', found: '47'