Submission #302601

#TimeUsernameProblemLanguageResultExecution timeMemory
302601Dremix10Comparing Plants (IOI20_plants)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; #define F first #define S second #define endl '\n' #define all(x) (x).begin(),(x).end() #define p(x) cerr<<#x<<" = "<<x<<endl; #define p2(x,y) cerr<<#x<<","<<#y<<" = "<<"("<<x<<"-"<<y<<")"<<endl; #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl; /// random mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<ll> distr; ll rnd(ll x, ll y){return distr(rng)%(y-x+1)+x;} vector<int> arr,bigger; struct ano{ int pos; bool operator<(const ano &x)const{ return bigger[pos]<bigger[x.pos]; } }; void init(int k, vector<int> r) { int n = r.size(); arr.assign(n,0); bigger.assign(n,0); int i,j; set<ano> s; vector<int> ini; for(i=0;i<n;i++){ if(r[i]==0){ for(j=1;j<k;j++) bigger[(i+j)%n]++; ini.push_back(i); } } for(auto x : ini) s.insert({x}); int curr = n; for(int t=0;t<n;t++){ int x = (*s.begin()).pos; s.erase({x}); arr[x] = curr--; //pv(arr) //for(auto xx : s) // cout<<xx.pos<<" "; //cout<<endl; //pv(bigger) //pv(zer) //pv(r) //cout<<endl; for(j=1;j<k;j++){ int nxt = (x+j)%n; if(r[nxt]==0 && arr[nxt]==0){ s.erase({nxt}); bigger[nxt]--; s.insert({nxt}); } else{ bigger[nxt]--; } int idx = x-j; if(idx<0)idx+=n; if(r[idx]>0){ r[idx]--; if(r[idx]==0){ for(j=1;j<k;j++){ int nxt = (idx+j)%n; if(r[nxt]==0 && arr[nxt]==0){ s.erase({nxt}); bigger[nxt]++; s.insert({nxt}); } else{ bigger[nxt]++; } } s.insert({idx}); } } } //pv(bigger) //pv(zer) //pv(r) } pv(arr) } int main (){ int n = 5; int k = 3; int t = 1000; while(t--){ vector<int> ARR={1,2,3,4,5}; vector<int> r(n); for(int i = 0;i<n;i++) r[i] = rnd(0,k-1); do{ int i,j; bool ok = 1; for(i=0;i<n;i++){ int pos = i+1; int cnt = 0; for(j=0;j<k-1;j++){ pos %= n; if(ARR[pos]>ARR[i])cnt++; pos++; } if(cnt!=r[i]){ ok = 0; break; } } if(ok){ //pv(r) //pv(ARR) init(k,r); if(ARR!=arr){ pv(arr) pv(ARR) pv(r) } } }while(next_permutation(all(arr))); } }

Compilation message (stderr)

/tmp/ccxR4t4m.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccpCeqci.o:plants.cpp:(.text.startup+0x0): first defined here
/tmp/ccxR4t4m.o: In function `main':
grader.cpp:(.text.startup+0x30d): undefined reference to `compare_plants(int, int)'
collect2: error: ld returned 1 exit status