제출 #986301

#제출 시각아이디문제언어결과실행 시간메모리
986301dorjderemThe Xana coup (BOI21_xanadu)C++17
5 / 100
1070 ms5816 KiB
#include <iostream> #include <vector> #include <queue> #include <unordered_map> #include <bitset> using namespace std; #define ull unsigned long long int main() { int n; cin >> n; vector<vector<int>> adj(n); for (int i = 0; i < n - 1; ++i) { int a, b; cin >> a >> b; adj[a - 1].push_back(b - 1); adj[b - 1].push_back(a - 1); } ull tree = 0; for (int i = 0; i < n; i++) { int a; cin >> a; if (a) tree |= (1 << i); } int ans = 1000; for (ull bit = 0; bit < (1 << n); bit++) { ull a = tree; for (int i = 0; i < n; i++) { if (bit & (1 << i)) { a ^= (1ULL << i); for (int nxt : adj[i]) { a ^= (1ULL << nxt); } } } if (a == 0) { ans = min(ans, __builtin_popcount(bit)); } } if (ans < 1000) cout << ans << endl; else cout << "impossible"; return 0; }

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

xanadu.cpp: In function 'int main()':
xanadu.cpp:33:27: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   33 |     for (ull bit = 0; bit < (1 << n); bit++)
      |                       ~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...