답안 #116358

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116358 2019-06-12T10:36:33 Z evpipis 고속도로 설계 (CEOI12_highway) C++17
56 / 100
4 ms 1404 KB
#include <bits/stdc++.h>
using namespace std;

//#define TEST

#ifndef TEST
#include "office.h"
#endif // TEST

#ifdef TEST
int GetN(){
    return 9;
}

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;
            }
        }

        int m = one.size();
        if ((m/3)%2 == 0 && 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{
            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

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);
     ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct - 20 queries, 4 points
2 Incorrect 2 ms 256 KB Output isn't correct - Protocol error
3 Incorrect 2 ms 256 KB Output isn't correct - Protocol error
4 Correct 2 ms 256 KB Output is correct - 200 queries, 4 points
5 Correct 2 ms 256 KB Output is correct - 251 queries, 4 points
6 Correct 2 ms 384 KB Output is correct - 302 queries, 4 points
7 Correct 2 ms 384 KB Output is correct - 350 queries, 4 points
8 Incorrect 2 ms 256 KB Output isn't correct - Protocol error
9 Incorrect 2 ms 256 KB Output isn't correct - Protocol error
10 Correct 2 ms 256 KB Output is correct - 500 queries, 4 points
11 Correct 2 ms 384 KB Output is correct - 1001 queries, 4 points
12 Correct 2 ms 384 KB Output is correct - 1001 queries, 4 points
13 Correct 2 ms 384 KB Output is correct - 1502 queries, 4 points
14 Correct 2 ms 384 KB Output is correct - 2003 queries, 4 points
15 Incorrect 2 ms 384 KB Output isn't correct - Protocol error
16 Correct 2 ms 384 KB Output is correct - 803 queries, 4 points
17 Correct 2 ms 384 KB Output is correct - 854 queries, 4 points
18 Incorrect 2 ms 384 KB Output isn't correct - Protocol error
19 Incorrect 2 ms 640 KB Output isn't correct - Protocol error
20 Incorrect 2 ms 640 KB Output isn't correct - Protocol error
21 Correct 3 ms 896 KB Output is correct - 20060 queries, 4 points
22 Correct 3 ms 896 KB Output is correct - 28061 queries, 4 points
23 Incorrect 3 ms 1276 KB Output isn't correct - Protocol error
24 Incorrect 4 ms 1276 KB Output isn't correct - Protocol error
25 Incorrect 4 ms 1404 KB Output isn't correct - Protocol error