QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#96143 | #5341. Shopping Malls | zoker# | AC ✓ | 17ms | 4288kb | C++17 | 3.7kb | 2023-04-13 13:44:10 | 2023-04-13 13:44:13 |
Judging History
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), adj[b][a] = min(adj[b][a], (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];
}
}
}
}
//dbg(adj[0][2], adj[1][2], adj[2][0]);
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
*/
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3644kb
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 0 1
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 11ms
memory: 4100kb
input:
166 409 0 3 24 0 4 42 0 5 5 0 5 23 0 5 42 0 6 5 0 7 7 0 7 38 0 10 29 0 16 45 0 17 34 0 18 18 0 22 45 0 23 5 0 23 8 0 23 26 0 23 42 0 25 36 0 28 34 0 30 27 0 32 45 0 33 18 0 33 36 0 35 4 0 38 7 0 38 38 0 40 35 0 41 45 0 42 5 0 42 16 0 42 23 0 42 42 0 44 9 0 44 29 0 44 41 1 5 5 1 5 19 1 5 23 1 5 42 1 ...
output:
3 37 36 42 6 5 0 3 69 71 67 3 0 8 2 5 6 3 37 36 40 3 136 137 143 146 3 0 1 4 0 8 10 16 81 84 86 91 97 6 5 2 35 39 44 49 52 62 30 1 0 3 69 4 1 7 43 73 74 78 82 88 92 9 10 3 37 36 45 49 50 115 3 69 71 76 5 2 35 39 44 49 50 115 119 3 136 137 143 147 152 154 162 4 1 7 43 73 74 78 82 88 89 125 155 0 8 10...
result:
ok 1000 lines
Test #3:
score: 0
Accepted
time: 10ms
memory: 4140kb
input:
157 387 0 3 38 0 4 25 0 5 5 0 5 8 0 5 22 0 5 40 0 7 7 0 7 36 0 8 38 0 12 31 0 14 8 0 16 24 0 18 39 0 21 16 0 24 43 0 25 5 0 25 40 0 26 27 0 27 37 0 31 5 0 32 33 0 37 16 0 37 40 0 40 28 0 41 7 0 41 36 0 44 6 0 44 40 0 45 5 0 45 22 0 45 40 0 47 20 0 47 34 1 4 24 1 5 5 1 5 22 1 5 40 1 6 41 1 7 5 1 9 9 ...
output:
1 8 5 0 7 40 71 105 102 107 111 5 0 7 40 71 105 102 104 101 8 7 40 71 105 130 132 136 141 5 0 7 40 41 44 49 57 61 29 2 3 1 4 1 8 4 98 104 108 109 112 7 40 71 64 66 5 0 7 40 41 44 49 57 61 150 1 3 10 4 1 9 1 4 35 33 42 47 51 3 1 4 127 131 135 140 8 9 12 18 22 27 1 9 11 13 19 26 28 0 7 40 71 105 130 1...
result:
ok 1000 lines
Test #4:
score: 0
Accepted
time: 12ms
memory: 4196kb
input:
175 445 0 5 5 0 5 18 0 5 21 0 5 34 0 5 38 0 6 5 0 7 7 0 7 34 0 13 34 0 15 18 0 20 16 0 20 26 0 21 5 0 21 38 0 23 34 0 24 5 0 26 21 0 30 37 0 33 21 0 34 7 0 34 34 0 38 5 0 38 21 0 38 38 0 39 9 0 39 26 0 39 38 1 5 5 1 5 16 1 5 21 1 5 38 1 7 4 1 7 27 1 7 37 1 9 9 1 9 36 1 15 24 1 18 28 1 20 4 1 21 5 1 ...
output:
8 1 2 58 55 57 56 4 3 7 35 63 61 66 68 13 14 0 5 9 7 35 63 92 122 124 127 129 128 98 4 3 7 35 63 61 66 68 13 14 16 1 2 148 151 155 157 160 162 164 5 0 27 31 38 39 98 102 2 148 151 150 6 5 1 2 58 1 2 148 151 150 7 35 63 61 59 3 1 2 89 86 88 4 3 8 10 15 0 27 31 38 46 51 110 111 115 2 148 151 155 156 1...
result:
ok 1000 lines
Test #5:
score: 0
Accepted
time: 17ms
memory: 4268kb
input:
198 515 0 4 7 0 5 5 0 5 24 0 5 44 0 6 18 0 6 30 0 6 43 0 7 7 0 7 40 0 13 23 0 15 38 0 18 19 0 20 4 0 20 38 0 24 5 0 24 44 0 25 45 0 27 20 0 30 36 0 30 45 0 32 7 0 36 28 0 38 45 0 39 41 0 40 7 0 40 9 0 40 40 0 43 31 0 44 5 0 44 24 0 44 44 0 46 8 0 47 26 0 47 42 0 47 45 1 1 29 1 3 48 1 4 4 1 5 5 1 5 2...
output:
2 73 79 80 84 2 133 138 144 153 6 8 44 76 78 80 84 0 1 38 37 47 50 146 143 5 2 170 166 171 2 39 46 49 55 59 61 90 119 5 9 10 13 4 5 6 3 40 45 36 7 0 4 5 6 8 44 76 107 137 7 0 4 5 2 103 99 5 9 11 17 21 27 32 5 2 133 138 144 154 157 121 3 6 5 2 133 130 139 2 133 138 144 148 15 16 19 4 11 17 21 27 29 1...
result:
ok 1000 lines
Test #6:
score: 0
Accepted
time: 16ms
memory: 4288kb
input:
195 516 0 1 34 0 5 5 0 5 13 0 5 25 0 5 45 0 7 3 0 7 7 0 7 34 0 7 41 0 13 49 0 14 40 0 17 12 0 17 24 0 20 7 0 22 5 0 22 45 0 23 49 0 25 40 0 28 32 0 30 21 0 33 9 0 35 7 0 35 41 0 36 45 0 36 49 0 37 26 0 39 5 0 39 25 0 39 37 0 39 45 0 41 4 0 42 19 0 42 48 1 2 14 1 3 45 1 5 5 1 5 25 1 5 45 1 6 29 1 7 3...
output:
2 7 3 70 73 6 5 13 14 82 5 11 12 18 22 60 91 121 2 11 19 25 27 63 61 4 7 3 70 73 68 69 1 35 33 36 70 4 7 12 19 20 5 11 12 18 22 60 91 0 7 12 19 20 21 59 90 119 151 185 6 2 7 8 42 75 106 135 169 174 179 4 7 12 19 20 21 59 90 119 151 185 187 188 6 5 13 14 111 109 116 6 5 13 20 21 59 90 119 126 122 5 1...
result:
ok 1000 lines