# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
673369 |
2022-12-20T11:50:35 Z |
1bin |
Rail (IOI14_rail) |
C++14 |
|
68 ms |
644 KB |
#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
/*
int getDistance(int a, int b){
cout << a << ' ' << b << endl;
int x;
cin >> x;
return x;
}*/
void findLocation(int n, int fi, int location[], int stype[]){
vector<pair<int, int>> v;
set<int> L, R;
for(int i = 1; i < n; i++){
int d = getDistance(0, i);
v.emplace_back(d, i);
}
sort(all(v));
location[0] = fi; stype[0] = 1;
if(n == 1) return;
auto [d0, t] = v[0];
location[t] = fi + d0; stype[t] = 2;
int l, r;
l = 0, r = t;
for(int i = 1; i < n - 1; i++){
auto&[d, x] = v[i];
int d1 = getDistance(t, x);
if(d0 + d1 == d){
int xl = getDistance(x, l);
if(l && L.find(-d + fi + location[l] + 2 * d0 + xl) != L.end()){
location[x] = location[l] + xl;
stype[x] = 2;
}
else{
location[x] = fi + 2 * d0 - d;
stype[x] = 1;
if(location[x] < fi) l = x, L.emplace(location[x] * 2);
}
}
else{
int xr = getDistance(r, x);
if(r != t && R.find(d + fi + location[r] - xr) != R.end()){
location[x] = location[r] - xr;
stype[x] = 1;
}
else{
location[x] = fi + d;
stype[x] = 2;
r = x;
R.emplace(location[x] * 2);
}
}
}
return;
}
/*
int main(void){
int n = 4, fi = 2, a[4], b[4];
findLocation(n, fi, a, b);
for(int i = 0; i < 4; i++) cout << a[i] << ' ' << b[i] << '\n';
return 0;
}*/
Compilation message
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:29:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
29 | auto [d0, t] = v[0];
| ^
rail.cpp:34:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
34 | auto&[d, x] = v[i];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
376 KB |
Output is correct |
8 |
Correct |
1 ms |
380 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
380 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
380 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
632 KB |
Output is correct |
2 |
Correct |
65 ms |
640 KB |
Output is correct |
3 |
Correct |
64 ms |
588 KB |
Output is correct |
4 |
Correct |
65 ms |
636 KB |
Output is correct |
5 |
Correct |
64 ms |
644 KB |
Output is correct |
6 |
Correct |
66 ms |
640 KB |
Output is correct |
7 |
Correct |
65 ms |
640 KB |
Output is correct |
8 |
Correct |
67 ms |
588 KB |
Output is correct |
9 |
Correct |
67 ms |
632 KB |
Output is correct |
10 |
Correct |
66 ms |
628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
588 KB |
Output is correct |
2 |
Correct |
68 ms |
628 KB |
Output is correct |
3 |
Correct |
65 ms |
624 KB |
Output is correct |
4 |
Correct |
64 ms |
608 KB |
Output is correct |
5 |
Correct |
66 ms |
644 KB |
Output is correct |
6 |
Correct |
65 ms |
624 KB |
Output is correct |
7 |
Correct |
65 ms |
632 KB |
Output is correct |
8 |
Correct |
64 ms |
632 KB |
Output is correct |
9 |
Correct |
65 ms |
632 KB |
Output is correct |
10 |
Correct |
67 ms |
624 KB |
Output is correct |
11 |
Correct |
65 ms |
632 KB |
Output is correct |
12 |
Correct |
64 ms |
636 KB |
Output is correct |
13 |
Correct |
64 ms |
640 KB |
Output is correct |
14 |
Correct |
65 ms |
632 KB |
Output is correct |
15 |
Correct |
67 ms |
588 KB |
Output is correct |
16 |
Correct |
65 ms |
632 KB |
Output is correct |
17 |
Correct |
64 ms |
636 KB |
Output is correct |
18 |
Correct |
65 ms |
628 KB |
Output is correct |
19 |
Correct |
65 ms |
636 KB |
Output is correct |
20 |
Correct |
65 ms |
636 KB |
Output is correct |