# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116365 | evpipis | Highway design (CEOI12_highway) | C++17 | 4 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 <bits/stdc++.h>
using namespace std;
//#define TEST
#ifndef TEST
#include "office.h"
#endif // TEST
#ifdef TEST
int GetN(){
return 14;
}
int isOnLine(int a, int b, int c){
int ans = 0;
printf("asked %d %d %d\n", a, b, c);
scanf("%d", &ans);
return ans;
}
void Answer(int a1, int b1, int a2, int b2){
printf("Answered %d %d %d %d\n", a1, b1, a2, b2);
}
#endif
#define pb push_back
vector<int> one, zero;
int main(){
int n = GetN();
for (int i = 1; i+2 <= n; i+=3){
if (isOnLine(i, i+1, i+2))
one.pb(i), one.pb(i+1), one.pb(i+2);
else
zero.pb(i), zero.pb(i+1), zero.pb(i+2);
}
if (zero.size() >= 6){
int i, j, k, stop = 0;
for (i = 0; i < 3; i++){
for (j = 3; j < 6; j++){
for (k = j+1; k < 6; k++){
if (isOnLine(zero[i], zero[j], zero[k]))
stop = 1;
if (stop)
break;
}
if (stop)
break;
}
if (stop)
break;
}
int a, b, cnt = 0;
for (int d = 0; d < 6; d++){
if (d == i || d == j || d == k || cnt == 2)
continue;
if (isOnLine(zero[i], zero[j], zero[d]) == 0){
if (cnt == 0)
a = d;
else
b = d;
cnt++;
}
}
Answer(zero[i], zero[j], zero[a], zero[b]);
}
else{
int f = -1;
for (int i = 0; i+6 < one.size(); i+=6){
if (isOnLine(one[i], one[i+3], one[i+6]) == 0){
f = i;
break;
}
}
//printf("after first for, f = %d\n", f), fflush(stdout);
int m = one.size();
if ((m/3)%2 == 0 && f == -1 && isOnLine(one[m-9], one[m-6], one[m-3]) == 0)
f = m-9;
//printf("after case, f = %d\n", f), fflush(stdout);
if (f != -1){
if (isOnLine(one[f], one[f+1], one[f+3]))
Answer(one[f], one[f+1], one[f+6], one[f+7]);
else
Answer(one[f], one[f+1], one[f+3], one[f+4]);
}
else{
//if (zero.size() == 0)
// Answer(0, 0, 0, 0);
vector<int> hel;
if (isOnLine(one[0], one[1], zero[0]) == 0)
hel.pb(zero[0]);
if (isOnLine(one[0], one[1], zero[1]) == 0)
hel.pb(zero[1]);
if (isOnLine(one[0], one[1], zero[2]) == 0)
hel.pb(zero[2]);
if (hel.size() == 1)
Answer(one[0], one[1], hel[0], n);
else
Answer(one[0], one[1], hel[0], hel[1]);
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |