Submission #832674

#TimeUsernameProblemLanguageResultExecution timeMemory
832674Theo830Comparing Plants (IOI20_plants)C++17
0 / 100
1 ms312 KiB
#include "plants.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define ii pair<ll,ll> #define pb push_back #define F first #define S second #define f(i,a,b) for(ll i = a;i < b;i++) ll arr[200005]; const ll INF = 1e9; void init(int k,vector<int>r){ ll n = r.size(); ll cur = n; while(1){ vector<ll>possible; f(i,0,n){ if(r[i] == 0){ possible.pb(i); } } if(possible.empty()){ break; } ll siz = possible.size(); bool ok[siz]; vector<ll>kame; f(i,0,siz){ ll dist = possible[(i+1)%siz] - possible[i]; if(dist <= 0){ dist += n; } if(dist >= k){ kame.pb(possible[i]); } } for(auto x:kame){ arr[x] = cur; r[x] = INF; ll s = k; ll pos = x; while(s--){ r[pos]--; pos--; if(pos < 0){ pos += n; } } } cur--; } return; } int compare_plants(int x, int y) { if(arr[x] == arr[y]){ return 0; } if(arr[x] > arr[y]){ return 1; } return -1; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:26:14: warning: unused variable 'ok' [-Wunused-variable]
   26 |         bool ok[siz];
      |              ^~
#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...