#include <bits/stdc++.h>
using namespace std;
//#define TEST
#ifndef TEST
#include "office.h"
#endif // TEST
#ifdef TEST
int GetN(){
return 10;
}
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);
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;
}
}
int m = one.size();
if ((m/3)%2 == 4 && f == -1 && isOnLine(one[m-9], one[m-6], one[m-3]))
f = m-9;
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{
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
highway.cpp: In function 'int main()':
highway.cpp:79:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i+6 < one.size(); i+=6){
~~~~^~~~~~~~~~~~
highway.cpp:75:49: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
Answer(zero[i], zero[j], zero[a], zero[b]);
^
highway.cpp:75:40: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
Answer(zero[i], zero[j], zero[a], zero[b]);
^
office.c: In function 'int isOnLine(int, int, int)':
office.c:85:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(0, "Protocol error");
^
office.c:88:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(0, "Protocol error");
^
office.c:92:37: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(false, "Too many questions");
^
office.c:83:7: warning: unused variable 'i' [-Wunused-variable]
int i;
^
office.c: In function 'void Answer(int, int, int, int)':
office.c:123:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(0, "Protocol error");
^
office.c:128:44: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if( (-_Apa[na1]==_N-3) && (na2!=na1) && (nb2!=na1) ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
office.c:130:30: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(true, "Correct");
^
office.c:132:36: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(false, "Wrong answer");
^
office.c:134:44: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if( (-_Apa[na2]==_N-3) && (na1!=na2) && (nb1!=na2) ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
office.c:136:30: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(true, "Correct");
^
office.c:138:36: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(false, "Wrong answer");
^
office.c:140:33: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(false, "Wrong answer");
^
office.c:142:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
_Fin(true, "Correct");
^
office.c:120:27: warning: unused variable 'pont' [-Wunused-variable]
int na1, nb1, na2, nb2, pont;
^~~~
office.c: In function 'void _doInit()':
office.c:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &_N);
~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
2 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
2 ms |
540 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
2 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
2 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
3 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
3 ms |
1024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
21 |
Runtime error |
4 ms |
1024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
22 |
Runtime error |
3 ms |
1280 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
23 |
Runtime error |
4 ms |
1536 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
24 |
Runtime error |
4 ms |
1664 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
25 |
Runtime error |
7 ms |
1788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |