QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#391032 | #8195. Satelity | Untitled0 | 0 | 1ms | 6204kb | C++14 | 3.7kb | 2024-04-16 12:11:07 | 2024-04-16 12:11:08 |
answer
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
// #define int ll
#define rep(i, s, e) for(int i = s, i##E = e; i <= i##E; ++i)
#define per(i, s, e) for(int i = s, i##E = e; i >= i##E; --i)
#define gmin(x, y) (x = min(x, y))
#define gmax(x, y) (x = max(x, y))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double f128;
typedef pair<int, int> pii;
#ifndef ONINE_JUDGE
#define debug(fmt, ...) fprintf(stderr, "[%d] " fmt "\n", __LINE__, ##__VA_ARGS__)
#else
#define debug(fmt, ...) 0
#endif
char gc() {
static char buf[1 << 20], *st, *ed;
if(st == ed) st = buf, ed = buf + fread(buf, 1, 1 << 20, stdin);
return st == ed ? EOF : *st++;
}
template<typename Int>
bool read(Int &x) {
int flg = 1, c = EOF;
while(!isdigit(c = gc()) && c != '-' && c != EOF);
if(c == EOF) return 0;
if(c == '-') flg = -1, x = 0;
else x = c - '0';
while(isdigit(c = gc())) x = x * 10 + c - '0';
x *= flg;
return 1;
}
template<typename Int, typename ...Args>
bool read(Int &x, Args& ...args) {
if(!read(x)) return 0;
return read(args...);
}
constexpr int N = 2005;
int n, p, m, fa[N], sz[N], id[N], tot;
char s[N][N];
bitset<N> to[N];
int Log(int x) {
if(x == 1) return 1;
int t = __lg(x);
return (1 << t) == x ? t : t + 1;
}
void slove() {
// debug("%d %d %d", n, p, m);
rep(i, 1, p) {
int u, v; read(u, v);
to[u][v] = to[v][u] = 1;
}
int l = 0, r = 0, lmx = 1, rmx = 1;
rep(i, 1, n) {
bool flg = 1;
per(j, i - 1, 1) if(to[i] == to[j]) {
fa[i] = j, id[i] = id[j] + 1, sz[i] = sz[j] + 1;
gmax(lmx, sz[i]);
flg = 0; break;
}
if(flg) ++l, fa[i] = i, sz[i] = 1;
}
rep(i, n + 1, n * 2) {
bool flg = 1;
per(j, i - 1, n + 1) if(to[i] == to[j]) {
fa[i] = j, id[i] = id[j] + 1, sz[i] = sz[j] + 1;
gmax(rmx, sz[i]);
flg = 0; break;
}
if(flg) ++r, fa[i] = i, sz[i] = 1;
}
// rep(i, 1, n * 2) debug("%d %d", id[i], sz[i]);
debug("%d %d %d %d", l, r, lmx, rmx);
if(l < r) {
rep(i, 1, n) {
if(fa[i] != i) continue;
s[i][++tot] = 'B';
rep(j, 1, n) if(j != i) s[j][tot] = 'A';
rep(j, n + 1, n * 2)
s[j][tot] = to[i][j] ? 'B' : 'C';
}
rep(x, 1, Log(lmx)) {
++tot;
rep(i, 1, n) s[i][tot] = id[i] >> (x - 1) & 1 ? 'C' : 'A';
rep(i, n + 1, n * 2) s[i][tot] = 'B';
}
if(rmx || lmx) rep(x, 1, Log(rmx)) {
++tot;
rep(i, n + 1, n * 2) s[i][tot] = id[i] >> (x - 1) & 1 ? 'C' : 'B';
rep(i, 1, n) s[i][tot] = 'A';
}
}
else {
rep(i, n + 1, n * 2) {
if(fa[i] != i) continue;
s[i][++tot] = 'B';
rep(j, n + 1, n * 2) if(j != i) s[j][tot] = 'A';
rep(j, 1, n) s[j][tot] = to[i][j] ? 'B' : 'C';
}
rep(x, 1, Log(rmx)) {
++tot;
rep(i, n + 1, n * 2) s[i][tot] = id[i] >> (x - 1) & 1 ? 'C' : 'A';
rep(i, 1, n) s[i][tot] = 'B';
}
if(rmx || lmx) rep(x, 1, Log(lmx)) {
++tot;
rep(i, 1, n) s[i][tot] = id[i] >> (x - 1) & 1 ? 'C' : 'B';
rep(i, n + 1, n * 2) s[i][tot] = 'A';
}
}
printf("%d\n", tot);
rep(i, 1, n * 2) puts(s[i] + 1);
rep(i, 1, n * 2) to[i].reset();
rep(i, 1, n * 2) fa[i] = id[i] = sz[i] = 0;
rep(i, 1, n * 2) rep(j, 1, tot) s[i][j] = 0;
tot = 0;
}
signed main() {
while(read(n, p, m)) slove();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 1ms
memory: 4316kb
input:
100 5340 10200 1 101 1 102 1 104 1 105 1 106 1 107 1 108 1 109 1 116 1 119 1 120 1 123 1 125 1 126 1 127 1 129 1 132 1 133 1 135 1 136 1 137 1 138 1 141 1 144 1 146 1 147 1 148 1 149 1 151 1 155 1 156 1 158 1 159 1 160 1 161 1 163 1 165 1 167 1 168 1 169 1 170 1 172 1 173 1 174 1 175 1 177 1 178 1 1...
output:
102 BBCBBBBBBCCCCCCBCCBBCCBCBBBCBCCBBCBBBBCCBCCBCBBBBCBCCCBBCBBBBCBCBCBBBBCBBBBCBBCBCBBCBCCCBBCBBCBBCCBCBB BCBBCBCBCCCBBBBCBCCBBBBCCBCBBCCBBBBCCCCCCCBCCCBCCBCCCCCCBCCCBBBCBCBCBCBCCBCBBCCBCCBBBBBBCCCCCCCBBBCBBB CBBCCBCCCBCBCBBCCCBBCCBCCBCBCCBBBBCCCBCBCCCCCBBCCBCBBCCCBBCBCBBBCCCCBBBCBBBCBCCCBCCCCCBCBC...
result:
ok correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 4316kb
input:
100 658 10200 1 104 1 148 1 169 1 175 1 177 1 181 1 187 1 188 2 132 2 190 3 119 3 147 3 154 3 163 3 165 3 177 3 184 3 199 4 102 4 105 4 130 4 132 4 138 4 160 4 183 4 192 4 199 5 113 5 152 5 153 5 165 5 186 5 194 6 111 6 114 6 134 6 155 6 199 7 109 7 120 7 128 7 131 7 136 7 143 7 191 8 104 8 107 8 17...
output:
102 CCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCBCCCCCBCBCCCBCCCCCBBCCCCCCCCCCCCBB CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCBB CCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCBCCCCCCCCBCBCCCCCCCCCCCBCCCCCCBCCCCCC...
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 6204kb
input:
100 9540 10200 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 110 1 111 1 112 1 113 1 114 1 115 1 116 1 117 1 118 1 119 1 120 1 121 1 122 1 123 1 124 1 125 1 126 1 127 1 128 1 129 1 131 1 132 1 133 1 134 1 135 1 136 1 137 1 138 1 139 1 140 1 141 1 142 1 143 1 144 1 145 1 146 1 147 1 148 1 1...
output:
102 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB BBBBBBBCBBBBBBBBBBBBBBBBBBBBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBBBBBBCBBBBB BBBBBBCBCBBBBBBBBBCBBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
ok correct
Test #4:
score: -7
Wrong Answer
time: 1ms
memory: 6040kb
input:
100 10000 10200 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 110 1 111 1 112 1 113 1 114 1 115 1 116 1 117 1 118 1 119 1 120 1 121 1 122 1 123 1 124 1 125 1 126 1 127 1 128 1 129 1 130 1 131 1 132 1 133 1 134 1 135 1 136 1 137 1 138 1 139 1 140 1 141 1 142 1 143 1 144 1 145 1 146 1 147 1 ...
output:
15 BBBBBBBBBBBBBBB BBBBBBBBCBBBBBB BBBBBBBBBCBBBBB BBBBBBBBCCBBBBB BBBBBBBBBBCBBBB BBBBBBBBCBCBBBB BBBBBBBBBCCBBBB BBBBBBBBCCCBBBB BBBBBBBBBBBCBBB BBBBBBBBCBBCBBB BBBBBBBBBCBCBBB BBBBBBBBCCBCBBB BBBBBBBBBBCCBBB BBBBBBBBCBCCBBB BBBBBBBBBCCCBBB BBBBBBBBCCCCBBB BBBBBBBBBBBBCBB BBBBBBBBCBBBCBB BBBBBBBBB...
result:
wrong answer detected: (1, 102) are not connected
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%