QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#318924#7184. Transport PlusesPhanDinhKhoi#WA 1ms3928kbC++203.6kb2024-02-01 11:03:362024-02-01 11:03:38

Judging History

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

  • [2024-02-01 11:03:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3928kb
  • [2024-02-01 11:03:36]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;

#define fi first
#define se second
#define left BAO
#define right ANH
#define pb push_back
#define pf push_front
#define mp make_pair
#define ins insert
#define btpc __builtin_popcount
#define btclz __builtin_clz

#define sz(x) (int)(x.size());
#define all(x) x.begin(), x.end()
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int d4x[4] = {1, 0, -1, 0}; int d4y[4] = {0, 1, 0, -1};
int d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1};

template<class X, class Y>
    bool minimize(X &x, const Y &y) {
        if (x > y)
        {
            x = y;
            return true;
        }
        return false;
    }
template<class X, class Y>
    bool maximize(X &x, const Y &y) {
        if (x < y)
        {
            x = y;
            return true;
        }
        return false;
    }

const int MOD = 1e9 + 7; //998244353

template<class X, class Y>
	void add(X &x, const Y &y) {
		x = (x + y);
		if(x >= MOD) x -= MOD;
	}

template<class X, class Y> 
	void sub(X &x, const Y &y) {
		x = (x - y);
		if(x < 0) x += MOD;
	}

/* Author : Le Ngoc Bao Anh, DUT, Da Nang */

const ll INF = 1e9;
const int N = 1e5 + 10;

ld dp[N];
pair<ld, ld> p[N];
int pX[105], pY[105];
int center[105][105];
bool locked[N];
pii prv[N];

ld dist(int x, int y) {
	return abs((p[x].fi - p[y].fi) * (p[x].fi - p[y].fi) + (p[x].se - p[y].se) * (p[x].se - p[y].se));
}

void BaoJiaoPisu() {
	int n, t; cin >> n >> t;
	vector<int> X, Y;
	for(int i = 1; i <= 2; i++) {
		cin >> p[i].fi >> p[i].se;
		X.pb(p[i].fi);
		Y.pb(p[i].se);
	}
	for(int i = 1; i <= n; i++) {
		int x, y; cin >> x >> y;
		X.pb(x);
		pX[x] = i;
		Y.pb(y);
		pY[y] = i;
		center[x][y] = i;
	}

	int cnt = 2;
	for(int i = 0; i < n + 2; i++) {
		for(int j = 0; j < n + 2; j++) {
			p[++cnt] = {X[i], Y[j]};
		}
	}

	for(int i = 1; i <= cnt; i++) dp[i] = INF;
	dp[1] = 0;
	
	for(int i = 1; i <= cnt; i++) {
		int u = 0;
		for(int j = 1; j <= cnt; j++) {
			if(!locked[j] && (!u || dp[u] > dp[j])) u = j;
		}
		if(!u) break;
		locked[u] = true;

		for(int j = 1; j <= cnt; j++) {
			if(dp[j] > dp[u]) {
				if(minimize(dp[j], dp[u] + dist(u, j))) prv[j] = {0, u};
				if(p[u].fi == p[j].fi && pX[(int)p[u].fi] && minimize(dp[j], dp[u] + t)) prv[j] = {pX[(int)p[u].fi], u};
				if(p[u].se == p[j].se && pY[(int)p[u].se] && minimize(dp[j], dp[u] + t)) prv[j] = {pY[(int)p[u].se], u};
				int par = max(center[(int)p[j].fi][(int)p[u].se], center[(int)p[u].fi][(int)p[j].se]);
				if(par && minimize(dp[j], dp[u] + t)) prv[j] = {par, u};
			}
		}
	}

	cout << fixed;
	cout << setprecision(6);
	cout << dp[2] << '\n';
	vector<pii> ans;
	int node = 2;
	while(node != 1) {
		ans.pb({prv[node].fi, node});
		node = prv[node].se;
	}
	reverse(all(ans));
	cout << ans.size() << '\n';
	for(auto x : ans) {
		cout << x.fi << " " << p[x.se].fi << " " << p[x.se].se << '\n';
	}
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    //online
    #endif

    int tc = 1, ddd = 0;
    // cin >> tc;
    while(tc--) {
        //ddd++;
        //cout << "Case #" << ddd << ": ";
        BaoJiaoPisu();
    }
}

詳細信息

Test #1:

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

input:

1 2
1 1
5 3
6 2

output:

4.000000
3
0 1.000000 2.000000
1 5.000000 2.000000
0 5.000000 3.000000

result:

ok correct

Test #2:

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

input:

2 1
1 1
6 1
1 3
6 3

output:

2.000000
2
1 1.000000 3.000000
2 6.000000 1.000000

result:

ok correct

Test #3:

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

input:

0 0
1 1
1 1

output:

0.000000
1
0 1.000000 1.000000

result:

ok correct

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3928kb

input:

0 0
100 100
0 0

output:

20000.000000
1
0 0.000000 0.000000

result:

wrong answer claimed 20000.0000000000, actual 141.4213562373