Submission #125181

# Submission time Handle Problem Language Result Execution time Memory
125181 2019-07-04T20:14:35 Z figter001 Highway design (CEOI12_highway) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "office.h"
#define _MaxN	100001
using namespace std;
/*
bool _Init = true;
int _digi = 129723562;
int _N, _Qnum, _maxQ1, _maxQ2, _maxQ4;
int _Apa[_MaxN];

void _Fin(bool OK, string S){
int point=0;
   if (OK) {
      if (_Qnum <= _maxQ4) {
         point = 4;
         S=" <=N/2+2";
    } else if (_Qnum <= _maxQ2) {
         point = 2;
         S=" <=2N/3";
    } else {
         point = 1;
         S=" <=N-3";
    }
    cout<<point<<endl;
    cout<<"Correct"<<endl;
    cout<<"#Questions= "<<_Qnum<<S<<endl;
    cout<<_digi<<endl;
    exit(0);
  }
  cout<<"0"<<endl;
  cout<<S<<endl;
  cout<<"#Questions= "<<_Qnum<<endl;
  cout<<_digi<<endl;
  exit(0);
}  /*_Fin*/

 void _doInit(){
  int x;
   cin>>_N;
  for (x = 1; x <= _N; x++) {
    _Apa[x] = -1;
  }
  _Qnum = 0;
  _maxQ1 = _N - 3;
  _maxQ2 = _N * 2 / 3;
  _maxQ4 = _N / 2+2;
}  /*diInit*/

int GetN(){
  if (_Init) {
    _doInit();
    _Init = false;
  }
  return _N;
}  /*GetN*/

int _Find(int x){
  int k;
  int Nx = x;
  while (_Apa[Nx] > 0) {
    Nx = _Apa[Nx];
  }
  while (x != Nx) {
    k = _Apa[x];
    _Apa[x] = Nx;
    x = k;
  }
  return Nx;
}  /*_Find*/

 int _Unio(int nn, int mm){
  int k;
  if (nn == mm) {
    return nn;
  }
  if (_Apa[nn] > _Apa[mm]) {
    k = nn;
    nn = mm;
    mm = k;
  }
  _Apa[nn] += _Apa[mm];
  _Apa[mm] = nn;
  return nn;
}  /*_Unio*/

int isOnLine(int x, int y, int z){
  int nx, ny, nz,nn;
  int nxn = 0, nyn = 0, nzn = 0;
  int i;
  if (_Init) {
    _Fin(0, "Protocol error");
  }
  if (x < 1 || x > _N || y < 1 || y > _N || z < 1 || z > _N) {
    _Fin(0, "Protocol error");
  }
  _Qnum++;
  if (_Qnum > _maxQ1)
    _Fin(false, "Too many questions");

  if (x == y || y == z || y==z) {
    return 1;
  }
  nx = _Find(x);
  ny = _Find(y);
  nz = _Find(z);
  if (nx == ny && ny == nz) {
    return 1;
  }

  nxn = -_Apa[nx];  nyn = -_Apa[ny];  nzn = -_Apa[nz];
  nn=nxn+nyn+nzn;
  if (nx==ny) nn-=nyn;
  if (nx==nz) nn-=nzn;
  if (ny==nz) nn-=nzn;

  if (nn <= _N - 3) {
    nx = _Unio(nx, ny);
    nx = _Unio(nx, nz);
    return 1;
  }

  return 0;
}  /*isOnLine*/
*/
bool vis[11][11][11];

void Answer(int a1, int b1, int a2, int b2){
  int n = GetN();
  vector<int> a = {1,2,3,4,5};
  do{
    vector<int> cur;
    cur.push_back(a[0]);
    cur.push_back(a[1]);
    cur.push_back(a[2]);
    sort(cur.begin(),cur.end());
    int x = cur[0],y = cur[1],z = cur[2];
    if(vis[x][y][z])continue;
    vis[x][y][z] = 1;
    int res = isOnLine(x,y,z);
    if(res == 1){
      Answer(x,y,cur[3],cur[4]);
      return;
    }
  }while(next_permutation(a.begin(),a.end()));
}

Compilation message

highway.cpp:35:4: warning: "/*" within comment [-Wcomment]
 }  /*_Fin*/
     
highway.cpp: In function 'void _doInit()':
highway.cpp:39:9: error: '_N' was not declared in this scope
    cin>>_N;
         ^~
highway.cpp:39:9: note: suggested alternative: '__N'
    cin>>_N;
         ^~
         __N
highway.cpp:41:5: error: '_Apa' was not declared in this scope
     _Apa[x] = -1;
     ^~~~
highway.cpp:43:3: error: '_Qnum' was not declared in this scope
   _Qnum = 0;
   ^~~~~
highway.cpp:43:3: note: suggested alternative: 'enum'
   _Qnum = 0;
   ^~~~~
   enum
highway.cpp:44:3: error: '_maxQ1' was not declared in this scope
   _maxQ1 = _N - 3;
   ^~~~~~
highway.cpp:44:3: note: suggested alternative: 'fmaxl'
   _maxQ1 = _N - 3;
   ^~~~~~
   fmaxl
highway.cpp:45:3: error: '_maxQ2' was not declared in this scope
   _maxQ2 = _N * 2 / 3;
   ^~~~~~
highway.cpp:45:3: note: suggested alternative: '__exp2'
   _maxQ2 = _N * 2 / 3;
   ^~~~~~
   __exp2
highway.cpp:46:3: error: '_maxQ4' was not declared in this scope
   _maxQ4 = _N / 2+2;
   ^~~~~~
highway.cpp:46:3: note: suggested alternative: 'fmaxl'
   _maxQ4 = _N / 2+2;
   ^~~~~~
   fmaxl
highway.cpp: In function 'int GetN()':
highway.cpp:50:7: error: '_Init' was not declared in this scope
   if (_Init) {
       ^~~~~
highway.cpp:50:7: note: suggested alternative: '_doInit'
   if (_Init) {
       ^~~~~
       _doInit
highway.cpp:54:10: error: '_N' was not declared in this scope
   return _N;
          ^~
highway.cpp:54:10: note: suggested alternative: '__N'
   return _N;
          ^~
          __N
highway.cpp: In function 'int _Find(int)':
highway.cpp:60:10: error: '_Apa' was not declared in this scope
   while (_Apa[Nx] > 0) {
          ^~~~
highway.cpp:64:9: error: '_Apa' was not declared in this scope
     k = _Apa[x];
         ^~~~
highway.cpp: In function 'int _Unio(int, int)':
highway.cpp:76:7: error: '_Apa' was not declared in this scope
   if (_Apa[nn] > _Apa[mm]) {
       ^~~~
highway.cpp:81:3: error: '_Apa' was not declared in this scope
   _Apa[nn] += _Apa[mm];
   ^~~~
highway.cpp: In function 'int isOnLine(int, int, int)':
highway.cpp:90:7: error: '_Init' was not declared in this scope
   if (_Init) {
       ^~~~~
highway.cpp:90:7: note: suggested alternative: '_Unio'
   if (_Init) {
       ^~~~~
       _Unio
highway.cpp:91:5: error: '_Fin' was not declared in this scope
     _Fin(0, "Protocol error");
     ^~~~
highway.cpp:91:5: note: suggested alternative: '_Find'
     _Fin(0, "Protocol error");
     ^~~~
     _Find
highway.cpp:93:20: error: '_N' was not declared in this scope
   if (x < 1 || x > _N || y < 1 || y > _N || z < 1 || z > _N) {
                    ^~
highway.cpp:93:20: note: suggested alternative: '__N'
   if (x < 1 || x > _N || y < 1 || y > _N || z < 1 || z > _N) {
                    ^~
                    __N
highway.cpp:94:5: error: '_Fin' was not declared in this scope
     _Fin(0, "Protocol error");
     ^~~~
highway.cpp:94:5: note: suggested alternative: '_Find'
     _Fin(0, "Protocol error");
     ^~~~
     _Find
highway.cpp:96:3: error: '_Qnum' was not declared in this scope
   _Qnum++;
   ^~~~~
highway.cpp:96:3: note: suggested alternative: 'enum'
   _Qnum++;
   ^~~~~
   enum
highway.cpp:97:15: error: '_maxQ1' was not declared in this scope
   if (_Qnum > _maxQ1)
               ^~~~~~
highway.cpp:97:15: note: suggested alternative: 'fmaxl'
   if (_Qnum > _maxQ1)
               ^~~~~~
               fmaxl
highway.cpp:98:5: error: '_Fin' was not declared in this scope
     _Fin(false, "Too many questions");
     ^~~~
highway.cpp:98:5: note: suggested alternative: '_Find'
     _Fin(false, "Too many questions");
     ^~~~
     _Find
highway.cpp:110:10: error: '_Apa' was not declared in this scope
   nxn = -_Apa[nx];  nyn = -_Apa[ny];  nzn = -_Apa[nz];
          ^~~~
highway.cpp:116:13: error: '_N' was not declared in this scope
   if (nn <= _N - 3) {
             ^~
highway.cpp:116:13: note: suggested alternative: '__N'
   if (nn <= _N - 3) {
             ^~
             __N
highway.cpp:89:7: warning: unused variable 'i' [-Wunused-variable]
   int i;
       ^
highway.cpp: At global scope:
highway.cpp:124:2: error: expected unqualified-id before '/' token
 */
  ^
highway.cpp:124:2: error: expected constructor, destructor, or type conversion before '/' token
highway.cpp: In function 'void Answer(int, int, int, int)':
highway.cpp:137:8: error: 'vis' was not declared in this scope
     if(vis[x][y][z])continue;
        ^~~
highway.cpp:138:5: error: 'vis' was not declared in this scope
     vis[x][y][z] = 1;
     ^~~
highway.cpp:128:7: warning: unused variable 'n' [-Wunused-variable]
   int n = GetN();
       ^
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);
     ~~~~~^~~~~~~~~~~