답안 #116356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116356 2019-06-12T10:35:45 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 == 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);
                
            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:98:31: error: too few arguments to function 'void Answer(int, int, int, int)'
                 Answer(0, 0, 0);
                               ^
In file included from highway.cpp:7:0:
office.h:3:13: note: declared here
 extern void Answer(int a1, int b1, int a2, int b2);
             ^~~~~~
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);
     ~~~~~^~~~~~~~~~~