제출 #232487

#제출 시각아이디문제언어결과실행 시간메모리
232487tjd229Secret Permutation (RMI19_permutation)C++14
컴파일 에러
0 ms0 KiB
#include "permutationc.h" #include <vector> using namespace std; int Tx[257], x[257]; int use[257]; int _N; bool recon(int ix,vector<int> &P) { int bk = P.back(); // if (ix == _N) { int d = bk - P[0]; if (d < 0) d = -d; return d == x[1]; } int nxt = bk + x[ix+1]; if (nxt <= _N && use[nxt] == 0) { use[nxt] = 1; P.push_back(nxt); if (recon(ix + 1, P)) return 1; P.pop_back(); use[nxt] = 0; } nxt = bk - x[ix+1]; if (nxt > 0 && use[nxt] == 0) { use[nxt] = 1; P.push_back(nxt); if (recon(ix + 1, P)) return 1; P.pop_back(); use[nxt] = 0; } return 0; } void solve(int N) { _N = N; int sum = 0; vector<int> P; for (int i = 1; i <= N; ++i) { vector<int> V; for (int j = 0; j < N; ++j) { int x = i + j; if (x > N) x -= N; V.push_back(x); } Tx[i]=query(V); sum += Tx[i]; use[i] = 0; } int T = sum / (N - 1); for (int i = 1; i <= N; ++i) x[i] = T-Tx[i] ; print(x); for (int i = 1; i <= N; ++i) { P.push_back(i); use[i] = 1; if (recon(1, P)) { answer(P); break; } P.pop_back(); use[i] = 0; } }

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

permutation.cpp: In function 'void solve(int)':
permutation.cpp:48:16: error: cannot convert 'std::vector<int>' to 'int*' for argument '1' to 'int query(int*)'
   Tx[i]=query(V);
                ^
permutation.cpp:55:2: error: 'print' was not declared in this scope
  print(x);
  ^~~~~
permutation.cpp:55:2: note: suggested alternative: 'int'
  print(x);
  ^~~~~
  int
permutation.cpp:59:12: error: cannot convert 'std::vector<int>' to 'int*' for argument '1' to 'void answer(int*)'
    answer(P);
            ^
stub.cpp: In function 'int query(int*)':
stub.cpp:15:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   fscanf(stdin, "%d", &x);
   ~~~~~~^~~~~~~~~~~~~~~~~
stub.cpp: In function 'int main(int, char**)':
stub.cpp:48:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   fscanf(stdin, "%d", &N);
   ~~~~~~^~~~~~~~~~~~~~~~~