답안 #536929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536929 2022-03-14T07:51:30 Z joelau Speedrun (RMI21_speedrun) C++14
컴파일 오류
0 ms 0 KB
#include "speedrun.h"
#include <bits/stdc++.h>

void assignHints(int subtask, int N, int A[], int B[]) {
    int deg[N+5];
    memset(deg,0,sizeof(deg));
    for (int i = 1; i < N; ++i) deg[A[i]]++, deg[B[i]]++;
    int x = 1;
    for (int i = 1; i <= N; ++i) if (deg[i] > deg[x]) x = i;
    setHintLen(20);
    for (int i = 0; i < 20; ++i) for (int j = 1; j <= N; ++j) if (x & (1<<i)) setHint(j,i+1,1);
}

void speedrun(int subtask, int N, int start) {
    int len = getLength();
    bitset<1005> visited;
    visited[start] = 1;
    int x = 0;
    for (int i = 0; i < 20; ++i) if (getHint(i+1)) x |= (1<<i);
    if (start != x) goTo(x), visited[x] = 1;
    for (int i = 1; i <= N; ++i) if (!visited[i]) goTo(i), goTo(x);
}

Compilation message

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:16:5: error: 'bitset' was not declared in this scope; did you mean 'std::bitset'?
   16 |     bitset<1005> visited;
      |     ^~~~~~
      |     std::bitset
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66,
                 from speedrun.cpp:2:
/usr/include/c++/10/bitset:751:11: note: 'std::bitset' declared here
  751 |     class bitset
      |           ^~~~~~
speedrun.cpp:16:18: error: 'visited' was not declared in this scope
   16 |     bitset<1005> visited;
      |                  ^~~~~~~
speedrun.cpp:15:9: warning: unused variable 'len' [-Wunused-variable]
   15 |     int len = getLength();
      |         ^~~