제출 #645494

#제출 시각아이디문제언어결과실행 시간메모리
645494TimDeeSpeedrun (RMI21_speedrun)C++17
컴파일 에러
0 ms0 KiB
/* Input format: * * N -- number of nodes * a1 b1 -- edge 1 * ... * a(N-1) b(N-1) -- edge N - 1 * x -- start node */ #include <iostream> #include <map> #include <set> //#include "speedrun.h" using namespace std; static map<int, map<int, bool>> mp; static int length = -1; static int queries = 0; static bool length_set = false; static int current_node = 0; static set<int> viz; static map<int, set<int>> neighbours; void setHintLen(int l) { if (length_set) { cerr << "Cannot call setHintLen twice" << endl; exit(0); } length = l; length_set = true; } void setHint(int i, int j, bool b) { if (!length_set) { cerr << "Must call setHintLen before setHint" << endl; exit(0); } mp[i][j] = b; } int getLength() { return length; } bool getHint(int j) { return mp[current_node][j]; } bool goTo(int x) { if (neighbours[current_node].find(x) == end(neighbours[current_node])) { ++queries; return false; } else { viz.insert(current_node = x); return true; } } //#include "speedrun.h" #include <bits/stdc++.h> using namespace std; void assignHints(int id,int n, int*a, int*b) { if (id==1) { setHintLen(n); for(int i=0;i<n-1;++i) { int u=a[i],v=b[i]; setHint(u,v,1); setHint(v,u,1); } } } void speedrun(int id,int n,int start) { } int main() { int N; cin >> N; vector<int>a(N),b(N); for (int i = 1; i < N; ++i) { cin >> a[i] >> b[i]; neighbours[a[i]].insert(b[i]); neighbours[b[i]].insert(a[i]); } assignHints(1, N, a, b); if (!length_set) { cerr << "Must call setHintLen at least once" << endl; exit(0); } cin >> current_node; viz.insert(current_node); speedrun(1, N, current_node); if (viz.size() < N) { cerr << "Haven't seen all nodes" << endl; exit(0); } cerr << "OK; " << queries << " incorrect goto's" << endl; return 0; }

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

speedrun.cpp: In function 'int main()':
speedrun.cpp:86:23: error: cannot convert 'std::vector<int>' to 'int*'
   86 |     assignHints(1, N, a, b);
      |                       ^
      |                       |
      |                       std::vector<int>
speedrun.cpp:60:36: note:   initializing argument 3 of 'void assignHints(int, int, int*, int*)'
   60 | void assignHints(int id,int n, int*a, int*b) {
      |                                ~~~~^
speedrun.cpp:98:20: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   98 |     if (viz.size() < N) {
      |         ~~~~~~~~~~~^~~