제출 #985308

#제출 시각아이디문제언어결과실행 시간메모리
985308SzymonKrzywda동굴 (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
#include"cave.h" #include <bits/stdc++.h> using namespace std; int tryCombination(int S[]); void answer(int S[],int D[]); void exploreCave(int N){ int S[N]; //int S_2[N]; // 0 0 0 0 0 // 1 1 1 1 1 // 1 1 1 1 0 //1110 //3102 int D_1(N); int D_2(N); for (int i=0; i<N; i++) D_2[i] = 1; bool good[N]; int D[N]; int w = 0,akt=0,w_2=0; while (w != -1){ if (akt == 0){ w = tryCombination(D_1); if (w == -1) D=D_1; for (int i=0; i<N; i++){ if (!good[i]){ D_1[i] = 1; w_2 = tryCombination(D_1); if (w_2 < w){ D_2[i] = 0; D_1[i] = 0; good[i] = true; } else if(w_2 > w){ good[i] = true; } else D_1[i] = 0; } } } else{ w = tryCombination(D_2); if (w == -1) D=D_2; for (int i=0; i<N; i++){ if (!good[i]){ D_2[i] = 0; w_2 = tryCombination(D_2); if (w_2 < w){ D_2[i] = 1; D_1[i] = 1; good[i] = true; } else if(w_2 > w){ good[i] = true; } else D_1[i] = 1; } } } akt = (akt+1)%2; } for (int i=0; i<N; i++){ S[i] = (S[i]+1)%2; D[i] = tryCombination(S); S[i] = (S[i]+1)%2; } answer(S,D); }

컴파일 시 표준 에러 (stderr) 메시지

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:21:32: error: invalid types 'int[int]' for array subscript
   21 |     for (int i=0; i<N; i++) D_2[i] = 1;
      |                                ^
cave.cpp:27:32: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   27 |             w = tryCombination(D_1);
      |                                ^~~
      |                                |
      |                                int
In file included from cave.cpp:1:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:28:27: error: incompatible types in assignment of 'int' to 'int [N]'
   28 |             if (w == -1) D=D_1;
      |                          ~^~~~
cave.cpp:31:24: error: invalid types 'int[int]' for array subscript
   31 |                     D_1[i] = 1;
      |                        ^
cave.cpp:32:42: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   32 |                     w_2 = tryCombination(D_1);
      |                                          ^~~
      |                                          |
      |                                          int
In file included from cave.cpp:1:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:34:28: error: invalid types 'int[int]' for array subscript
   34 |                         D_2[i] = 0;
      |                            ^
cave.cpp:35:28: error: invalid types 'int[int]' for array subscript
   35 |                         D_1[i] = 0;
      |                            ^
cave.cpp:41:29: error: invalid types 'int[int]' for array subscript
   41 |                     else D_1[i] = 0;
      |                             ^
cave.cpp:46:32: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   46 |             w = tryCombination(D_2);
      |                                ^~~
      |                                |
      |                                int
In file included from cave.cpp:1:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:47:27: error: incompatible types in assignment of 'int' to 'int [N]'
   47 |             if (w == -1) D=D_2;
      |                          ~^~~~
cave.cpp:50:24: error: invalid types 'int[int]' for array subscript
   50 |                     D_2[i] = 0;
      |                        ^
cave.cpp:51:42: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   51 |                     w_2 = tryCombination(D_2);
      |                                          ^~~
      |                                          |
      |                                          int
In file included from cave.cpp:1:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:53:28: error: invalid types 'int[int]' for array subscript
   53 |                         D_2[i] = 1;
      |                            ^
cave.cpp:54:28: error: invalid types 'int[int]' for array subscript
   54 |                         D_1[i] = 1;
      |                            ^
cave.cpp:60:29: error: invalid types 'int[int]' for array subscript
   60 |                     else D_1[i] = 1;
      |                             ^