Submission #83202

#TimeUsernameProblemLanguageResultExecution timeMemory
83202qkxwsm철로 (IOI14_rail)C++14
0 / 100
91 ms3424 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; template<class T> void readi(T &x) { T input = 0; bool negative = false; char c = ' '; while (c < '-') { c = getchar(); } if (c == '-') { negative = true; c = getchar(); } while (c >= '0') { input = input * 10 + (c - '0'); c = getchar(); } if (negative) { input = -input; } x = input; } template<class T> void printi(T output) { if (output == 0) { putchar('0'); return; } if (output < 0) { putchar('-'); output = -output; } int aout[20]; int ilen = 0; while(output) { aout[ilen] = ((output % 10)); output /= 10; ilen++; } for (int i = ilen - 1; i >= 0; i--) { putchar(aout[i] + '0'); } return; } template<class T> void ckmin(T &a, T b) { a = min(a, b); } template<class T> void ckmax(T &a, T b) { a = max(a, b); } long long randomize(long long mod) { return ((1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod; } #define MP make_pair #define PB push_back #define PF push_front #define LB lower_bound #define UB upper_bound #define fi first #define se second #define debug(x) cerr << #x << " = " << x << endl; const long double PI = 4.0 * atan(1.0); const long double EPS = 1e-20; #define MAGIC 347 #define SINF 10007 #define CO 1000007 #define INF 1000000007 #define BIG 1000000931 #define LARGE 1696969696967ll #define GIANT 2564008813937411ll #define LLINF 2696969696969696969ll #define MAXN 5013 long long normalize(long long x, long long mod = INF) { return (((x % mod) + mod) % mod); } typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int N, P; int dist[MAXN][MAXN]; int query(int x, int y) { if (x > y) swap(x, y); return (x == y ? 0 : (dist[x][y] ? dist[x][y] : dist[x][y] = getDistance(x, y))); } void findLocation(int n, int first, int location[], int stype[]) { N = n; P = first; //let's say we know all the answers to 0 stype[0] = 1; location[0] = P; int A = -1, B = -1, ext, D; ext = INF; for (int i = 0; i < N; i++) { if (i == 0) continue; int cur = query(0, i); if (cur < ext) { A = i; ext = cur; } } stype[A] = 2; location[A] = P + ext; ext = INF; for (int i = 0; i < N; i++) { if (i == A) continue; int cur = query(A, i); if (cur < ext) { B = i; ext = cur; } } stype[B] = 1; location[B] = location[A] - ext; D = ext; debug(B); debug(A); for (int i = 0; i < N; i++) { if (i == A || i == B) continue; int da = query(A, i), db = query(B, i), d; if (da < db) { //it's on the left of them d = da; stype[i] = 1; location[i] = location[A] - d; } else { //it's to the right of them d = db; stype[i] = 2; location[i] = location[B] + d; } } // for (int i = 0; i < N; i++) // { // cerr << stype[i] << ' ' << location[i] << endl; // } //for a given 0: you can find the next 1 //1 for type C, 2 for type D, 0 for nothing! } /* 2 3 1 4 2 16 2 18 */

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:121:27: warning: variable 'D' set but not used [-Wunused-but-set-variable]
  int A = -1, B = -1, ext, D;
                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...