結果
問題 | No.1652 XOR Inequalities |
ユーザー | Kude |
提出日時 | 2021-08-20 23:14:42 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,227 bytes |
コンパイル時間 | 4,622 ms |
コンパイル使用メモリ | 271,696 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-14 06:47:38 |
合計ジャッジ時間 | 11,285 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 2 ms
6,820 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | AC | 2 ms
6,816 KB |
testcase_44 | AC | 2 ms
6,820 KB |
testcase_45 | AC | 2 ms
6,816 KB |
testcase_46 | AC | 2 ms
6,816 KB |
testcase_47 | AC | 2 ms
6,820 KB |
testcase_48 | WA | - |
testcase_49 | AC | 2 ms
6,820 KB |
testcase_50 | AC | 2 ms
6,816 KB |
testcase_51 | WA | - |
testcase_52 | AC | 2 ms
6,816 KB |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template<class T> void chmax(T& a, const T& b) {a = max(a, b);} template<class T> void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; const unsigned long long INF = 1002003004005006007; template<class T> std::vector<unsigned long long> dijkstra(std::vector<std::vector<std::pair<int,T>>>& to, int s=0) { struct QueElem { int v; unsigned long long c; bool operator<(const QueElem a) const {return c > a.c;} QueElem(int v, unsigned long long c): v(v), c(c) {} }; std::priority_queue<QueElem> q; std::vector<unsigned long long> dist(to.size(), INF); dist[s] = 0; q.emplace(s, 0); while(!q.empty()) { QueElem qe = q.top(); q.pop(); int u = qe.v; unsigned long long c = qe.c; if (c > dist[u]) continue; for(auto vc: to[u]) { int v = vc.first; unsigned long long nc = c + vc.second; if (nc < dist[v]) { dist[v] = nc; q.emplace(v, nc); } } } return dist; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int n2 = 1 << n; VI a(n2); rep(i, n2) cin >> a[i]; vector<vector<P>> to(n2); rep(i, n2) rep(j, n2) if (a[j] != -1) { int k = i ^ j; to[i].emplace_back(k, a[j]); } auto dist1 = dijkstra(to); rep(i, n2) if (a[i] == -1) { a[i] = (dist1[i] == INF ? (1 << 30) - 1 : dist1[i]); } to = vector<vector<P>>(n2); rep(i, n2) rep(j, n2) if (a[j] != -1) { int k = i ^ j; to[i].emplace_back(k, a[j]); } auto dist2 = dijkstra(to); rep(i, n2) if (i && dist2[i] < a[i]) { cout << "No" << endl; return 0; } cout << "Yes" << endl; rep(i, n2) cout << a[i] << " \n"[i + 1 == n2]; }