QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#218748 | #5523. Graph Problem With Small $n$ | isaunoya | WA | 1952ms | 3900kb | C++23 | 2.6kb | 2023-10-18 17:55:57 | 2023-10-18 17:55:58 |
Judging History
answer
#include <bits/stdc++.h>
#include <ctime>
#ifndef LOCAL
#define debug(...) 42
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif
#define rep1(a) for (int i = 0; i < a; i++)
#define rep2(i, a) for (int i = 0; i < a; i++)
#define rep3(i, a, b) for (int i = a; i < b; i++)
#define rep4(i, a, b, c) for (int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define pb emplace_back
using namespace std;
template <typename T, typename T2> void cmin(T &x, const T2 &y) {
x = x < y ? x : y;
}
template <typename T, typename T2> void cmax(T &x, const T2 &y) {
x = x > y ? x : y;
}
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
template <class T> using vc = vector<T>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
mt19937 rng(time(NULL));
const int inf = 1000000000;
const ll lnf = 1000000000000000000;
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
void solve() {
int n;
cin >> n;
vc<vi> g(n, vi(n));
rep(i, n) rep(j, n) {
char c;
cin >> c;
if (c == '1')
g[i][j] = 1;
else
g[i][j] = 0;
}
int l = n / 2;
int r = n - l;
vi p(n);
iota(all(p), 0);
vc<vi> ans(n, vi(n));
while (clock() * 1. / CLOCKS_PER_SEC < 1.95) {
shuffle(all(p), rng);
vi ll(p.begin(), p.begin() + l);
vi rr(p.begin() + l, p.end());
// debug(ll,rr);
int full = 0;
vc<pii> avail;
vi tmp;
auto solve = [&](auto &solve, int u, int v, int s) {
if (s == full) {
avail.pb(u, v);
return;
}
for (auto x : tmp) {
if ((!(s >> x & 1)) && g[v][x]) {
solve(solve, u, x, s | (1 << x));
}
}
};
full = 0, tmp = ll;
for (auto x : tmp)
full |= 1 << x;
for (auto u : tmp)
solve(solve, u, u, 1 << u);
auto a = avail;
avail.clear();
full = 0, tmp = rr;
for (auto x : tmp)
full |= 1 << x;
for (auto u : tmp)
solve(solve, u, u, 1 << u);
auto b = avail;
avail.clear();
// debug(a, b);
for (auto [x, y] : a) {
for (auto [z, w] : b) {
if (g[y][z]) {
ans[x][w] = ans[w][x] = 1;
}
}
}
}
rep(i, n) {
rep(j, n) cout << ans[i][j];
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1358ms
memory: 3780kb
input:
4 0110 1010 1101 0010
output:
0001 0001 0000 1100
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 1339ms
memory: 3900kb
input:
6 010001 101000 010100 001010 000101 100010
output:
010001 101000 010100 001010 000101 100010
result:
ok 6 lines
Test #3:
score: 0
Accepted
time: 1348ms
memory: 3696kb
input:
4 0111 1011 1101 1110
output:
0111 1011 1101 1110
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 1577ms
memory: 3632kb
input:
23 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 000000000...
output:
00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 000000000000...
result:
ok 23 lines
Test #5:
score: 0
Accepted
time: 1870ms
memory: 3708kb
input:
23 00010100000000000101000 00000000010000000001000 00000000000001000000001 10000000000000000010000 00000000000000000000000 10000000000000000000000 00000001000000000000000 00000010000000000010000 00000000000001000000000 01000000000000000000000 00000000000000000000000 00000000000000000000000 000000000...
output:
00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 000000000000...
result:
ok 23 lines
Test #6:
score: 0
Accepted
time: 1952ms
memory: 3848kb
input:
23 00001000000000000000000 00001000010001000000000 00000000000101000010000 00001000000100000000000 11010000010011000100000 00000000000100000000000 00000000000000000000001 00000000000000000101000 00000000000000000000000 01001000000000101010010 00000000000000000000101 00110100000010001000000 000010000...
output:
00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 000000000000...
result:
ok 23 lines
Test #7:
score: 0
Accepted
time: 1940ms
memory: 3760kb
input:
23 01000000000001101001100 10000001101000000000000 00000100000100010000100 00000000000000001011000 00000100001000000000000 00101000000000001000001 00000000000000000000000 01000000000000000000000 01000000000100000010000 00000000000001000000011 01001000000000010000000 00100000100001000100001 000000000...
output:
00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 000000000000...
result:
ok 23 lines
Test #8:
score: -100
Wrong Answer
time: 1948ms
memory: 3900kb
input:
23 00000000010001001001010 00100010001101110000001 01000001000100110000000 00000011010001101100100 00000000010000010001000 00000000000000001001000 01010001000000000000001 00110010000000000000010 00000000011000100100000 10011000101000100000000 01000000110010101010000 01100000000000000000000 000000000...
output:
01101111110110110100101 10000100000000000010100 10000100000110000000100 00000100000000000010000 10000111110110100110101 11111011110111110111111 10001100000010000010100 10001100000100000010100 10001100000110000010100 10001100000000000000100 00000000000010000000100 10101101100010010110100 101011101011...
result:
wrong answer 1st lines differ - expected: '01111111110111110110111', found: '01101111110110110100101'