제출 #846416

#제출 시각아이디문제언어결과실행 시간메모리
846416vjudge1ČVENK (COI15_cvenk)C++17
0 / 100
3055 ms524288 KiB
#include <bits/stdc++.h> #define lint long long #define endl '\n' #define pii pair<int, int> #define pll pair<lint, lint> #define For(i,n) for (int i = 0; i < n; i++) #define FOR For(i, n) using namespace std; const int N = 1e5; map<pii, int> vis[N]; map<pii, int> visc; map<pii, lint> dist; void validpush(queue<pair<int, pair<lint, pii>>>& q, int tourist, int depth, int x, int y) { if (x >= 1e9 || y >= 1e9) return; if (x < 0 || y < 0) return; if ((x & y)) return; if (vis[tourist][{x,y}]) return; q.push({tourist, {depth, {x,y}}}); } int main() { int n; cin >> n; vector<pii> ts(n); FOR { int x,y; cin >> x >> y; ts[i] = {x,y}; } queue<pair<int, pair<lint, pair<int, int>>>> q; lint fdepth = -1; lint mn = 2e18; FOR q.push({ i, { 0ll, { ts[i].first, ts[i].second } } }); while (!q.empty()) { int tourist = q.front().first; lint depth = q.front().second.first; int x = q.front().second.second.first; int y = q.front().second.second.second; q.pop(); if (vis[tourist][{x,y}]) continue; vis[tourist][{x,y}] = true; visc[{x,y}]++; //cerr << "depth tourist=" << tourist << " x,y=" << x << "," << y << " " << "depth=" << depth << endl; dist[{x,y}] += depth; if (visc[{x,y}] == n) { cout << dist[{x,y}] << endl; return 0; fdepth = depth; mn = min(mn, dist[{x,y}]); //cerr << x << " " << y << endl; continue; } validpush(q, tourist, depth+1, x, y+1); validpush(q, tourist, depth+1, x-1, y); validpush(q, tourist, depth+1, x, y-1); validpush(q, tourist, depth+1, x+1, y); } cout << mn << endl; }

컴파일 시 표준 에러 (stderr) 메시지

cvenk.cpp: In function 'int main()':
cvenk.cpp:32:55: warning: variable 'fdepth' set but not used [-Wunused-but-set-variable]
   32 |  queue<pair<int, pair<lint, pair<int, int>>>> q; lint fdepth = -1; lint mn = 2e18;
      |                                                       ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...