Submission #955448

#TimeUsernameProblemLanguageResultExecution timeMemory
955448yoav_sNewspapers (CEOI21_newspapers)C++17
6 / 100
475 ms279492 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> v; typedef vector<v> vv; typedef vector<vv> vvv; typedef pair<ll,ll> p; typedef vector<p> vp; typedef vector<vp> vvp; typedef vector<vvp> vvvp; typedef pair<ll, p> tri; typedef vector<tri> vtri; typedef vector<vtri> vvtri; typedef vector<vvtri> vvvtri; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<vvb> vvvb; #define f first #define s second #define pb push_back #define eb emplace_back #define all(v) (v).begin(),(v).end() const ll INF = 1e18; const ll mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll N, M; cin >> N >> M; vv graph(N); for (ll i= 0; i < M; i++) { ll a, b; cin >> a >> b; graph[a-1].pb(b-1); graph[b-1].pb(a-1); } v next((1ll << N)); for (ll i= 0; i < (1ll << N); i++) { for (ll j = 0; j < N; j++) { if (i & (1 << j)) { for (ll x : graph[j]) next[i] |= (1 << x); } } } vvp stateGraph((1ll << N)); for (ll i = 0; i < (1 << N); i++) { for (ll j = 0; j < N; j++) { if (i & (1 << j)) stateGraph[i].eb(next[i ^ (1 << j)], j); } } vb visited((1 << N), false); ll start = (1 << N) - 1; ll end = 0; stack<ll> dfs; dfs.push(start); while (!dfs.empty()) { auto top = dfs.top(); dfs.pop(); if (visited[top]) continue; visited[top] = true; for (auto x : stateGraph[top]) dfs.push(x.f); } if (visited[end]) cout << "YES\n1\n1\n"; else cout << "NO\n"; return 0; }

Compilation message (stderr)

newspapers.cpp: In function 'int main()':
newspapers.cpp:70:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   70 |         if (visited[top]) continue; visited[top] = true;
      |         ^~
newspapers.cpp:70:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   70 |         if (visited[top]) continue; visited[top] = true;
      |                                     ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...