제출 #551982

#제출 시각아이디문제언어결과실행 시간메모리
551982aadit_ambadkarBurza (COCI16_burza)C++11
48 / 160
76 ms2784 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back vector<int>v[402], q[402]; int n, k, level[402], st[402], dr[402], pz; void dfs(int u, int p) { if (u==p) return; if (u) { level[u]=level[p]+1; } if (level[u]==k-1) { st[u]=pz++; dr[u]=pz; } st[u]=pz; for (auto i : v[u]) { if (i!=p) dfs(i, u); } dr[u]=pz; } bool dp[402][(1<<20)]; bool solve() { dp[0][0] = 1; for(int i = 1; i < n; ++i) q[st[i]].push_back(i); for(int i = 0; i < pz; ++i) { for(int j = 0; j < (1<<k); ++j) { if (!dp[i][j]) continue; for(int jj = 0; jj < q[i].size(); ++jj) { int it = q[i][jj]; if (!(j >> level[it] & 1)) dp[dr[it]][j | (1<<level[it])] = 1; } } } for(int j = 0; j < (1<<k); ++j) if (dp[pz][j]) return 1; return 0; } int main() { cin >> n >> k; if (k*k >= n) { cout << "DA\n"; return 0; } for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; a--; b--; v[a].push_back(b); v[b].push_back(a); } level[0]=-1; dfs(0, -1); cout << (solve() ? "DA\n" : "NE\n"); }

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

burza.cpp: In function 'bool solve()':
burza.cpp:36:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for(int jj = 0; jj < q[i].size(); ++jj)
      |                             ~~~^~~~~~~~~~~~~
#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...
#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...