This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i64 = long long;
void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char* x) { cerr << '"' << x << '"'; } void __print(const string& x) { cerr << '"' << x << '"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template<typename T, typename V> void __print(const pair<T, V>& x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template<typename T> void __print(const T& x) { int f = 0; cerr << '{'; for (auto& i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#define ln "\n"
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a; i<=b; ++i)
#define ar array
int Bit(int mask, int b) { return (mask >> b) & 1; }
const ll base = 311, MOD = 998244353, M = 1e9 + 7, INF = 1e18;
// getDistance(station_i, station_j)
// type 1:down, 2: up
void findLocation(int N, int first, int location[], int stype[]) {
vector<vector<int>> d(N, vector<int>(N, 1e8));
auto print = [&](int a[]) -> void {
cerr << "{";
rep(i, 0, N - 1)
cerr << a[i] << " ";
cerr << "}\n";
};
fill_n(stype, N, 0);
stype[0] = 1;
location[0] = first;
rep(i, 0, N - 1) d[i][i] = 0;
vector<int> vis(N);
vis[0] = 1;
int u = 0;
rep(_, 2, N) {
int v = -1;
rep(j, 0, N - 1) if (!vis[j]) {
d[u][j] = getDistance(u, j);
if (v == -1 || d[u][v] > d[u][j])
v = j;
}
int t = -1;
rep(j, 0, N - 1) if (vis[j]) {
if (d[j][v] < d[u][v]) {
if (t == -1 || d[t][u] > d[j][u])
t = j;
}
}
if (t == -1) {
stype[v] = 3 - stype[u];
if (stype[u] == 1)
location[v] = location[u] + d[u][v];
else
location[v] = location[u] - d[u][v];
}
else {
if (stype[u] == stype[t]) {
stype[v] = 3 - stype[u];
if (stype[u] == 1)
location[v] = location[u] + d[u][v];
else
location[v] = location[u] - d[u][v];
}
else {
stype[v] = stype[u];
if (stype[u] == 1)
location[v] = location[t] - d[t][v];
else
location[v] = location[t] + d[t][v];
}
}
vis[v] = true;
u = v;
}
// print(location);
}
Compilation message (stderr)
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:21:10: warning: variable 'print' set but not used [-Wunused-but-set-variable]
21 | auto print = [&](int a[]) -> void {
| ^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |