Submission #823084

#TimeUsernameProblemLanguageResultExecution timeMemory
823084ymmComparing Plants (IOI20_plants)C++17
14 / 100
4054 ms13404 KiB
#include "plants.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= l; --x) typedef long long ll; typedef std::pair<int,int> pii; typedef std::pair<ll,ll> pll; using namespace std; const int N = 200'010; vector<int> A[N]; int val[N]; int n, k; void init(int k, std::vector<int> r) { ::k = k; n = r.size(); LoopR (x,0,n) { vector<int> z; Loop (i,0,n) { if (r[i] == 0) z.push_back(i); } int p = -1; Loop (i,0,z.size()) { if (z[i] - (i == 0? z.back() - n: z[i-1]) >= k) { p = z[i]; break; } } assert(p != -1); Loop (ii,p-k+1,p) { int i = (ii+n)%n; if (r[i] != -1) r[i]--; } r[p] = -1; val[p] = x; } //int mx = 0; //while (val[mx] != n-1) // ++mx; //vector<int> vec = {mx}; //Loop (ii,mx+1,mx+n) { // int i = ii%n; // while (val[vec.back()] < val[i]) // vec.pop_back(); // A[i].push_back(vec.back()); // vec.push_back(i); //} //vec = {mx}; //LoopR (ii,mx-n+1,mx) { // int i = (ii+n)%n; // while (val[vec.back()] < val[i]) // vec.pop_back(); // A[i].push_back(vec.back()); // vec.push_back(i); //} } bool vis[N]; bool dfs(int v, int dst) { if (v == dst) return 1; vis[v] = 1; for (int u : A[v]) { if (!vis[u] && dfs(u, dst)) return 1; } return 0; } int compare_plants(int x, int y) { if (val[x] > val[y]) return 1; else return -1; //memset(vis, 0, n); //if (dfs(x, y)) // return -1; //memset(vis, 0, n); //if (dfs(y, x)) // return 1; //return 0; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:3:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
      |                                        ^
plants.cpp:25:3: note: in expansion of macro 'Loop'
   25 |   Loop (i,0,z.size()) {
      |   ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...