답안 #116349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116349 2019-06-12T10:26:35 Z evpipis 고속도로 설계 (CEOI12_highway) C++17
컴파일 오류
0 ms 0 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 == 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: In function 'int isOnLine(int, int, int)':
highway.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &ans);
     ~~~~~^~~~~~~~~~~~
highway.cpp: In function 'int main()':
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);
     ~~~~~^~~~~~~~~~~
/tmp/ccodvP1Y.o: In function `GetN()':
office.c:(.text+0x130): multiple definition of `GetN()'
/tmp/ccEyf182.o:highway.cpp:(.text+0x0): first defined here
/tmp/ccodvP1Y.o: In function `isOnLine(int, int, int)':
office.c:(.text+0x1d0): multiple definition of `isOnLine(int, int, int)'
/tmp/ccEyf182.o:highway.cpp:(.text+0x10): first defined here
/tmp/ccodvP1Y.o: In function `Answer(int, int, int, int)':
office.c:(.text+0x3c0): multiple definition of `Answer(int, int, int, int)'
/tmp/ccEyf182.o:highway.cpp:(.text+0x80): first defined here
collect2: error: ld returned 1 exit status