Submission #1213126

#TimeUsernameProblemLanguageResultExecution timeMemory
1213126Rawlat_vanakRotating Lines (APIO25_rotate)C++20
Compilation error
0 ms0 KiB
#include "rotate.h" #include <bits/stdc++.h> using namespace std; //#define int long long #define speedIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); //#define mod 1000000007 #define f first #define s second #define pii pair<int,int> #define pb push_back const int M=50000; vector<int> final; void rotate(vector<int> t, int x){ //cout<<"rotate "; for(int i:t){ //cout<<i<<' '; final[i]=(final[i]+x)%M; } //cout<<"by "<<x<<'\n'; } void energy(int n, vector<int> v){ vector<pii> w(n); for(int i=0;i<n;i++){ w[i]={v[i],i}; } sort(w.begin(),w.end()); set<pair<pii,int>> a; for(int i=0;i<n;i++){ a.insert({{w[i].f,i},w[i].s}); } //will work with w, w[i].s is the og index. // a.f.f is value, a.f.s is the sorted index and a.s is the og index. int idx=0; vector<bool> marked(n,false); while(idx<n){ if(marked[idx]){ idx++; continue; } marked[idx]=true; if(w[idx].f<M/2){ auto it=a.upper_bound({{w[idx].f+M/2,1e9},1e9}); it--; // j st w[j]<=w[i]+M/2<w[j+1] auto element=*it; if(element.f.s-idx>=n/2){ //rotate({w[idx].s},w[element.f.s].f+M/2-w[idx].f); a.erase({{w[idx].f,idx},w[idx].s}); w[idx].f=(w[element.f.s].f+M/2)%M; a.insert({{w[idx].f,idx},w[idx].s}); marked[element.f.s]=true; }else{ //rotate({w[idx].s},w[(element.f.s+1)%n].f+M/2-w[idx].f); a.erase({{w[idx].f,idx},w[idx].s}); w[idx].f=(w[(element.f.s+1)%n].f+M/2)%M; a.insert({{w[idx].f,idx},w[idx].s}); marked[(element.f.s+1)%n]=true; } }else{ auto it=a.lower_bound({{w[idx].f-M/2,0},0}); //it--; // j st w[j-1]<w[i]+M/2<=w[j] auto element=*it; if(idx-element.f.s>=n/2){ //rotate({w[idx].s},w[element.f.s].f+M/2-w[idx].f); a.erase({{w[idx].f,idx},w[idx].s}); w[idx].f=(w[element.f.s].f+M/2)%M; a.insert({{w[idx].f,idx},w[idx].s}); marked[element.f.s]=true; }else{ //rotate({w[idx].s},w[(element.f.s-1)%n].f+M/2-w[idx].f); a.erase({{w[idx].f,idx},w[idx].s}); int lmao=(element.f.s-1)%n; if(lmao<0) lmao+=n; w[idx].f=(w[lmao].f+M/2)%M; a.insert({{w[idx].f,idx},w[idx].s}); marked[lmao]=true; } } idx++; } }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccot9nkS.o: in function `rotate(std::vector<int, std::allocator<int> >, int)':
grader.cpp:(.text+0x410): multiple definition of `rotate(std::vector<int, std::allocator<int> >, int)'; /tmp/ccG1v3nq.o:rotate.cpp:(.text+0x610): first defined here
collect2: error: ld returned 1 exit status