Submission #599900

#TimeUsernameProblemLanguageResultExecution timeMemory
5999008e7Rail (IOI14_rail)C++17
30 / 100
65 ms476 KiB
//Challenge: Accepted #include <bits/stdc++.h> #include "rail.h" using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ...b ){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r){ while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 5005 #define pii pair<int, int> #define ff first #define ss second const int inf = 1e9; void findLocation(int N, int first, int location[], int stype[]) { vector<int> dl(N, 0), dr(N, 0); dl[0] = inf; for (int i = 1;i < N;i++) { dl[i] = getDistance(0, i); } location[0] = first; stype[0] = 1; if (N == 1) return; int rid = min_element(dl.begin(), dl.end()) - dl.begin(); dr[rid] = inf; int llen = dl[rid]; location[rid] = first + dl[rid]; stype[rid] = 2; vector<pii> vl, vr; debug("rid", rid); for (int i = 0;i < N;i++) { if (i != rid) { dr[i] = getDistance(rid, i); if (!i) continue; if (dl[i] - dr[i] == llen) { if (dr[i] < llen) { location[i] = location[rid] - dr[i]; stype[i] = 1; } else { vl.push_back({dr[i], i}); } debug("lef", i); } } } int lid = min_element(dr.begin(), dr.end()) - dr.begin(); for (int i = 0;i < N;i++) { if (i == rid) dl[i] = dr[lid]; else if (i && dl[i] - dr[i] != llen) { debug("rig", i); dl[i] = dr[i] - dr[lid]; vr.push_back({dl[i], i}); } } debug("lid", lid, "rid", rid); sort(vl.begin(), vl.end()), sort(vr.begin(), vr.end()); int lef = 0, rig = rid; for (auto [dis, id]:vl) { int p = getDistance(lef, id), guess = 2 * location[rig] - location[lef] - (location[rid] - dis); if (p != guess) { location[id] = location[lef] + p; stype[id] = 2; rig = id; } else { location[id] = location[rid] - dis; stype[id] = 1; lef = id; } } lef = lid, rig = rid; for (auto [dis, id]:vr) { location[id] = location[lid] + dis; int p = getDistance(rig, id), guess = location[id] + location[rig] - 2 * location[lef]; if (p != guess) { location[id] = location[rig] - p; stype[id] = 1; lef = id; } else { location[id] = location[lid] + dis; stype[id] = 2; rig = id; } } pary(stype,stype + N); pary(location, location + N); }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
rail.cpp:40:2: note: in expansion of macro 'debug'
   40 |  debug("rid", rid);
      |  ^~~~~
rail.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
rail.cpp:52:5: note: in expansion of macro 'debug'
   52 |     debug("lef", i);
      |     ^~~~~
rail.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
rail.cpp:60:4: note: in expansion of macro 'debug'
   60 |    debug("rig", i);
      |    ^~~~~
rail.cpp:13:20: warning: statement has no effect [-Wunused-value]
   13 | #define debug(...) 0
      |                    ^
rail.cpp:65:2: note: in expansion of macro 'debug'
   65 |  debug("lid", lid, "rid", rid);
      |  ^~~~~
rail.cpp:14:19: warning: statement has no effect [-Wunused-value]
   14 | #define pary(...) 0
      |                   ^
rail.cpp:95:2: note: in expansion of macro 'pary'
   95 |  pary(stype,stype + N);
      |  ^~~~
rail.cpp:14:19: warning: statement has no effect [-Wunused-value]
   14 | #define pary(...) 0
      |                   ^
rail.cpp:96:2: note: in expansion of macro 'pary'
   96 |  pary(location, location + N);
      |  ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...