# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
246378 | thebes | Highway design (CEOI12_highway) | C++14 | 8 ms | 1404 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "office.h"
#include <bits/stdc++.h>
using namespace std;
int N, M, i, j;
vector<int> seg, cur, mis;
int main(){
N = GetN();
for(j=1,M=N;j<=M;j*=3){
cur.clear();
for(i=1;i<=M/j;i++)
cur.push_back(i*j);
M -= (M%(3*j));
while(cur.size()%3){
seg.push_back(cur.back());
cur.pop_back();
}
for(i=0;i<(int)cur.size();i+=3){
int res = isOnLine(cur[i],cur[i+1],cur[i+2]);
if(!res){
if(j>1){
res = isOnLine(cur[i],cur[i+1],cur[i+1]-1);
if(res) Answer(cur[i], cur[i+1], cur[i+2], cur[i+2]-1);
else Answer(cur[i], cur[i]-1, cur[i+1], cur[i+2]);
return 0;
}
else{
assert(false);
}
}
}
}
while(seg.size()>2){
int sz = (int)seg.size()-1;
int res = isOnLine(seg[sz-2], seg[sz-1], seg[sz]);
printf("%d %d %d\n",seg[sz-2],seg[sz-1],seg[sz]);
if(!res){
if(!isOnLine(seg[sz-2], seg[sz], seg[sz]-1)){
if(seg[sz-2]-1>seg[sz-1]) Answer(seg[sz-2],seg[sz-2]-1,seg[sz],seg[sz]-1);
else if(!isOnLine(seg[sz-1],seg[sz],seg[sz]-1)) Answer(seg[sz-2],seg[sz-1],seg[sz],seg[sz]-1);
else{seg.erase(seg.begin()+sz-1);continue;}
}
else Answer(seg[sz-1]-1, seg[sz-1], seg[sz-2], seg[sz]);
return 0;
}
else{
seg.erase(seg.begin()+sz-1);
seg.erase(seg.begin()+sz-1);
}
}
Answer(seg[0], seg[0]-1, seg[1], seg[1]-1);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |