QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#346735#4779. Train delaysPetroTarnavskyiCompile Error//C++202.2kb2024-03-08 22:05:402024-03-08 22:05:41

Judging History

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

  • [2024-03-08 22:05:41]
  • 评测
  • [2024-03-08 22:05:40]
  • 提交

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 pair<int, int> PII;
typedef long double db;

struct Connection
{
	int a, b;
	int m, t, p, d;
};

const int N = 1047 + 200;

map<string, int> mp;
Connection c[N];
int cntCon[N];
const db INF = 1e9 + 47;
const int HOUR = 60;
db d[N];
bool used[N];

void clear(int n)
{
	mp.clear();
	FOR (i, 0, n)
	{
		used[i] = false;
		d[i] = INF;
	}
}

int add(string& s)
{
	if (!mp.count(s))
		mp[s] = SZ(mp);
	return mp[s];
}

int dif(int t1, int t2)
{
	if (t1 <= t2)
		return t2 - t1;
	return t2 - t1 + HOUR;
}

db expec(int i, int j)
{
	if(c[i].b != c[j].a)
		return INF;
	db res = c[i].t + (1 - c[i].p / 100.0) * dif((c[i].m + c[i].t) % HOUR, c[j].m);
	FOR(del, 1, c[i].d + 1)
	{
		res += c[i].p / 100.0 / c[i].d * (del + dif((c[i].m + c[i].t + del) % HOUR, c[j].m));
	}
	return res;
}

void solve()
{
	string start, end;
	cin >> start >> end;
	
	int n;
	cin >> n;
	
	clear(n);
	int st = add(start);
	int en = add(end);
	
	FOR(i, 0, HOUR)
	{
		c[i] = {-1, st, i, 0, 0, 0};
	}
	FOR (i, HOUR, n + HOUR)
	{
		string s1, s2;
		cin >> s1 >> s2 >> c[i].m >> c[i].t >> c[i].p >> c[i].d;
		c[i].a = add(s1);
		c[i].b = add(s2);
	}
	FOR(i, 0, n + HOUR)
		d[i] = INF;
	FOR(i, 0, HOUR)
	{
		c[n + HOUR + i] = {en, -2, i, 0, 0, 0};
		d[n + HOUR + i] = 0;
	}
	n += 2 * HOUR;
	
	FOR(i, 0, n)
	{
		int v = -1;
		FOR(u, 0, n)
			if (!used[u] && (v == -1 || d[u] < d[v]))
				v = u;
		used[v] = true;
		FOR(j, 0, n)
			if (!used[j])
			{
				d[j] = min(d[j], d[v] + expec(j, v));
			}
	}
	db ans = INF;
	FOR (i, 0, HOUR)
		ans = min(ans, d[i]);
	if (ans + 47 > INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		cout << ans << '\n';
	}
	clear(n);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(15);
	
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}
	
	return 0;
}
123

详细

answer.code:143:1: error: expected unqualified-id before numeric constant
  143 | 123
      | ^~~