QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96141#5341. Shopping Mallszoker#WA 2ms3676kbC++173.6kb2023-04-13 13:39:012023-04-13 13:39:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 13:39:01]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3676kb
  • [2023-04-13 13:39:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt")

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using ii = pair<ll,ll>;
using vii = vector<ii>;
using ld = long double;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree < T, null_type, less<T>,
rb_tree_tag,
tree_order_statistics_node_update >;

#ifdef SA_DEBUG
template <class T>
void print(T a) {cerr << a << endl;}
template <class T, class... V> 
void print(T a, V... b) {cerr << a << ", "; print(b...);}
#define dbg(...) cerr << "[" << __LINE__ << "] " << #__VA_ARGS__ << " :: ", print(__VA_ARGS__)
#else
#define dbg(...) 7
#endif

#define eb emplace_back
#define fi first
#define se second

const ll INFL = 2e18;
const int INF = 1e9;
const double PI = acos(-1);
const ll mod = 1e9+7;

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

template<class T, class V> 
ostream& operator << (ostream &s, pair<T, V> a){
	s << a.fi << ' ' << a.se; return s;
}

template<class T, class V> 
istream& operator >> (istream &s, pair<T, V> &a){
	s >> a.fi >> a.se; return s;
}

template<class T> 
ostream& operator << (ostream &s, vector<T> a){
	for(int i = 0; i < (int)a.size(); i++){
		if(i > 0)s << ' ' ; 
		s << a[i];
	} return s;
}

template<class T> 
istream& operator >> (istream &s, vector<T> &a){
	for(T &x : a)s >> x; 
	return s;
}

template<class T> 
void input(T a[], int l, int r, istream &s = cin){
	while(l <= r)s >> a[l++];
}

template<class T> 
void output(T a[], int l, int r, bool en = true, ostream &s = cout){
	while(l <= r){ s << a[l++];
		if(l <= r) s << ' ';
	} if(en)s << "\n";
}



const int N = 2e2+3, K = 26;
//====================================================================//
ld adj[N][N];
int par[N][N];
int p[N][3];
ld dist(int a, int b){
	return hypot((p[a][0] - p[b][0]) * 5, p[a][1] - p[b][1], p[a][2] - p[b][2]);
}
void solve(int l, int r){
	if(par[l][r] == -1)return;
	solve(l, par[l][r]);
	cout << par[l][r] << " ";
	solve(par[l][r], r);
}
void testcase(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++)adj[i][j] = INF;
		adj[i][i] = 0;
	
		cin >> p[i][0] >> p[i][1] >> p[i][2];
	}
	
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		string s;
		cin >> s;
		if(s == "walking")adj[a][b] = min(adj[a][b], dist(a, b)), adj[b][a] = min(adj[b][a], dist(b, a));
		else if(s == "lift")adj[a][b] = min(adj[a][b], (ld)1);
		else if(s == "escalator")adj[a][b] = min(adj[a][b], (ld)1), adj[b][a] = min(adj[b][a], 3 * dist(b, a));
		else adj[a][b] = min(adj[a][b], dist(a, b)), adj[b][a] = min(adj[b][a], dist(b, a));
	}
	memset(par, -1, sizeof par);
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(adj[i][j] > adj[i][k] + adj[k][j]){
					par[i][j] = k;
					adj[i][j] = adj[i][k] + adj[k][j];
				}
			}
		}
	}
	
	int q;
	cin >> q;
	while(q--){
		int a, b;
		cin >> a >> b;
		if(a == b){
			cout << a << "\n";
			continue;
		}
		cout << a << " ";
		solve(a, b);
		cout << b << "\n";
	}
	
	return;
}





int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int T = 1;
	//cin >> T;
	
	for(int qq = 1; qq <= T; ++qq){
		//cout << "Case #" << qq << ": ";
		testcase();
	}
	return 0;
}
/*
6 7
3 2 3
3 5 3
2 2 3
2 6 4
1 1 3
1 4 2
0 1 walking
0 2 lift
1 2 stairs
2 3 walking
3 4 escalator
5 3 escalator
4 5 walking
1
5 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3676kb

input:

6 7
3 2 3
3 5 3
2 2 3
2 6 4
1 1 3
1 4 2
0 1 walking
0 2 lift
1 2 stairs
2 3 walking
3 4 escalator
5 3 escalator
4 5 walking
5
0 1
1 2
3 5
5 3
5 1

output:

0 1
1 0 2
3 4 5
5 3
5 3 2 1

result:

wrong answer 5th lines differ - expected: '5 3 2 0 1', found: '5 3 2 1'