# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
565041 | 2022-05-20T08:04:07 Z | AbdullahMW | 저장 (Saveit) (IOI10_saveit) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define ll int #define pb push_back #define f first #define s second using namespace std; vector <ll> gr[1005]; vector <pair <ll, ll>> bfs(ll xx) { ll cnt = 0; vector <pair <ll, ll>> ret; queue <ll> q; unordered_map <ll, bool> vis; q.push(xx); ret.pb({xx, 0}); vis[xx] = true; while (q.size()) { ll x = q.front(); q.pop(); vis[x] = true; cnt++; for (auto v : gr[x]) { if (!vis[v]) { q.push(v); ret.pb({v, cnt}); } } } return ret; } /*ll encode_bit(ll b) { return b; }*/ void encode(ll n, ll h, ll p, ll a[], ll b[]) { for (ll i = 0; i < p; i++) { gr[a[i]].pb(b[i]); gr[b[i]].pb(a[i]); } for (ll i = 0; i < h; i++) { vector <pair <ll, ll>> vec = bfs(i); sort(vec.begin(), vec.end()); for (auto v : vec) { for (ll b = 0; b < 10; b++) { encode_bit((1 << b) & v.s); } } } }