Submission #645011

#TimeUsernameProblemLanguageResultExecution timeMemory
645011kingfran1907Drawing (CEOI22_drawing)C++14
100 / 100
257 ms43704 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long llint; const int maxn = 1e6+10; const int base = 31337; const int mod = 1e9+7; const int inf = 0x3f3f3f3f; const int logo = 20; const int off = 1 << logo; const int treesiz = off << 1; int n; vector< int > graph[maxn]; pair< pair<int, int>, int > niz[maxn]; int sol[maxn]; llint ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) { return (llint)a.X * (b.Y - c.Y) + (llint)b.X * (c.Y - a.Y) + (llint)c.X * (a.Y - b.Y); } bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) { return ccw(niz[0].X, a.X, b.X) >= 0; } int t = 0; void solve(int x, int parr) { //printf("solve: %d\n", x); sol[x] = niz[t++].Y; for (int tren : graph[x]) { if (tren == parr) continue; solve(tren, x); } } int main() { scanf("%d", &n); for (int i = 1; i < n; i++) { int a, b; scanf("%d%d", &a, &b); graph[a].push_back(b); graph[b].push_back(a); } for (int i = 0; i < n; i++) { int x, y; scanf("%d%d", &x, &y); niz[i] = {{x, y}, i + 1}; } sort(niz, niz+n); sort(niz+1, niz+n, cmp); //for (int i = 0; i < n; i++) // printf("%d %d -- %d\n", niz[i].X.X, niz[i].X.Y, niz[i].Y); solve(1, 0); for (int i = 1; i <= n; i++) printf("%d ", sol[i]); printf("\n"); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
Main.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   scanf("%d%d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...