QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#85258 | #5670. Group Guests | whatever | WA | 727ms | 642892kb | C++17 | 5.8kb | 2023-03-07 14:27:43 | 2023-03-07 14:54:09 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define vi vector <int>
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
#define uint unsigned int
#define ull unsigned long long
#define ld long double
#define i128 __int128
using namespace std;
const int N = 4e6 + 7, mod = 1e9 + 7;
namespace solver {
mt19937_64 orz(114514);
int n, h, su[N], sv[N], deg[N], vis[N], fae[N];
int ehd[N], ev[N], enx[N], eid;
void eadd(int u, int v) {
++eid, enx[eid] = ehd[u], ev[eid] = v, ehd[u] = eid;
}
int use[N];
int fa[N], dfn[N], low[N], idtot;
ull F[N], val[N];
vi e[N], vc[N];
void dfs(int x) {
dfn[x] = low[x] = ++idtot;
for(int i = ehd[x]; i; i = enx[i])
if(!dfn[ev[i]])
fa[ev[i]] = x, fae[ev[i]] = i, use[i >> 1] = true, dfs(ev[i]);
else if(dfn[ev[i]] < dfn[x] && !use[i >> 1]) {
ull cur = F[i >> 1] = orz();
val[x] ^= cur;
val[ev[i]] ^= cur;
}
}
int siz[N];
void dfs2(int x) {
siz[x] = 0;
for(int i = ehd[x]; i; i = enx[i])
if(dfn[ev[i]] > dfn[x])
siz[x] += 1;
for(auto v : e[x]) {
dfs2(v);
siz[x] += siz[v];
val[x] ^= val[v];
}
}
void link(int u, int v) {
++n;
su[n] = u, sv[n] = v;
}
int hd[N], to[N], nx[N];
inline int SZ(int x, int y, int z) {
int all = n;
if(fa[x] == y || fa[x] == z) {
all = siz[x];
}
if(fa[y] == x) {
all -= siz[y] + 1;
if(fa[x] != z) --all;
}
if(fa[z] == x) {
all -= siz[z] + 1;
if(fa[x] != y) --all;
}
return all;
}
pair < int, int > work() {
eid = 1;
// cout << "deg seq = ";
// L(i, 1, h) {
// cout << deg[i] << ' ';
// }
// cout << endl;
if(n == 1) {
return make_pair(1, 0);
}
L(i, 1, n) {
++deg[su[i]];
++deg[sv[i]];
}
int ok = n == h;
L(i, 1, h)
ok &= deg[i] == deg[1];
// cout << h << " : deg seq = ";
// L(i, 1, h)
// cout << deg[i] << ' ';
// cout << endl;
if(ok && n != 3) {
return make_pair(1, 0);
}
L(i, 1, n) {
int u = su[i], v = sv[i];
if(deg[u] > deg[v]) swap(u, v);
else if(deg[u] == deg[v] && u > v) swap(u, v);
to[i] = v;
nx[i] = hd[u];
hd[u] = i;
}
L(i, 1, n) {
eadd(su[i], sv[i]);
eadd(sv[i], su[i]);
}
dfs(1);
L(i, 2, h) e[fa[i]].emplace_back(i);
dfs2(1);
L(i, 2, h) F[fae[i] >> 1] = val[i];
L(i, 1, h) {
for(int id = hd[i]; id; id = nx[id])
vis[to[id]] = id;
for(int id = hd[i]; id; id = nx[id]) {
int j = to[id];
for(int di = hd[j]; di; di = nx[di]) {
int k = to[di];
if(!vis[k]) continue;
ull ij = F[id];
ull jk = F[di];
ull ik = F[vis[k]];
// cout << i << ' ' << j << ' ' << k << endl;
int ok = 1;
if(ij == ik) {
if(SZ(i, j, k) & 1)
ok = 0;
}
if(ij == jk) {
if(SZ(j, k, i) & 1)
ok = 0;
}
if(ik == jk) {
if(SZ(k, i, j) & 1)
ok = 0;
}
if(ok)
return make_pair(0, 0);
}
}
for(int id = hd[i]; id; id = nx[id])
vis[to[id]] = 0;
}
return make_pair(0, 1);
}
void clear() {
L(i, 1, max(n, h))
su[i] = sv[i] = 0, deg[i] = 0,
e[i].clear(), dfn[i] = 0, low[i] = 0, fa[i] = 0, hd[i] = 0, vis[i] = 0,
ehd[i] = 0, use[i] = 0, F[i] = 0, val[i] = 0, fa[i] = 0, vc[i].clear();
n = h = 0, eid = 1, idtot = 0;
}
}
int n, h, f[N];
vi son[N];
int ehd[N], ev[N], enx[N], eid = 1;
void eadd(int u, int v) {
++eid, ev[eid] = v, enx[eid] = ehd[u], ehd[u] = eid;
}
inline int find(int x) {
return f[x] == x ? x : f[x] = find(f[x]);
}
int su[N], sv[N];
vi G[N];
queue < int > q;
int deg[N], del[N], usee[N];
void ban(int u) {
del[u] = true;
for(int i = ehd[u]; i; i = enx[i]) if(!del[ev[i]]) {
--deg[ev[i]];
if(deg[ev[i]] <= 2) q.push(ev[i]);
}
}
void gank(int u, int v, int id) {
if(deg[u] == 2) swap(u, v);
for(int j = ehd[v]; j; j = enx[j]) {
if(!del[ev[j]] && ev[j] != u) {
usee[id >> 1] = usee[j >> 1] = true;
ban(u), ban(v);
}
}
}
int id[N];
void Main() {
cin >> n >> h, eid = 1;
L(i, 1, max(n, h))
G[i].clear(), son[i].clear(),
ehd[i] = 0, deg[i] = 0, del[i] = 0, usee[i] = 0;
L(i, 1, h)
f[i] = i;
set < pair < int, int > > st;
L(i, 1, n) {
int u, v;
cin >> u >> v;
if(u > v) swap(u, v);
st.insert(make_pair(u, v));
assert(u != v);
assert(1 <= u && u <= h);
assert(1 <= v && v <= h);
eadd(u, v);
eadd(v, u);
su[i] = u, sv[i] = v;
deg[u] += 1;
deg[v] += 1;
}
L(i, 1, h) {
if(deg[i] <= 2) {
q.push(i);
}
}
while(!q.empty()) {
int u = q.front();
q.pop();
if(del[u]) continue;
for(int i = ehd[u]; i; i = enx[i]) {
int v = ev[i];
if(!del[u] && !del[v]) {
if((deg[u] == 1 && deg[v] == 2) || (deg[v] == 1 && deg[u] == 2)) {
gank(u, v, i);
break;
}
}
}
}
L(i, 1, n) if(!usee[i]) {
f[find(su[i])] = find(sv[i]);
}
L(i, 1, n) if(!usee[i]) {
G[find(su[i])].emplace_back(i);
}
L(i, 1, h) {
son[find(i)].emplace_back(i);
}
int cnt1 = 0, cnt2 = 0;
L(i, 1, h) if(find(i) == i) {
if(sz(G[i]) % 2 == 0) {
continue;
}
solver :: n = 0;
solver :: h = sz(son[i]);
L(j, 0, sz(son[i]) - 1)
id[son[i][j]] = j + 1;
for(auto &t : G[i]) {
int u = id[su[t]];
int v = id[sv[t]];
solver :: link(u, v);
}
auto pr = solver :: work();
cnt1 += pr.first;
cnt2 += pr.second;
solver :: clear();
}
cout << cnt1 << ' ' << cnt2 << '\n';
// cout << n << " and " << h << endl;
}
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
Main();
// int t; cin >> t; while(t--) Main();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 91ms
memory: 378560kb
input:
2 4 1 2 3 4
output:
2 0
result:
ok single line: '2 0'
Test #2:
score: 0
Accepted
time: 73ms
memory: 378452kb
input:
2 3 1 2 3 1
output:
0 0
result:
ok single line: '0 0'
Test #3:
score: 0
Accepted
time: 87ms
memory: 378636kb
input:
5 5 1 2 2 3 2 4 5 2 5 4
output:
0 0
result:
ok single line: '0 0'
Test #4:
score: 0
Accepted
time: 612ms
memory: 482372kb
input:
999990 666660 1 2 1 5 1 7 1 8 1 9 1 10 2 4 2 6 2 9 2 10 3 4 4 8 5 8 6 7 6 10 11 13 11 15 11 20 12 17 12 19 13 16 13 19 14 16 14 19 15 17 15 18 16 17 16 19 17 18 17 20 21 26 21 27 21 29 22 26 22 27 22 29 23 26 23 30 24 26 24 28 25 27 25 30 26 27 26 29 28 29 31 33 31 40 32 35 33 35 33 37 33 38 33 39 3...
output:
383 523
result:
ok single line: '383 523'
Test #5:
score: 0
Accepted
time: 596ms
memory: 480672kb
input:
999990 666660 1 2 1 3 1 5 1 8 2 4 2 7 3 8 3 9 3 10 4 5 4 10 5 9 6 7 6 9 9 10 11 12 11 14 11 19 11 20 12 16 13 17 13 19 14 15 14 16 15 16 15 18 16 18 16 19 17 20 18 20 21 24 21 26 21 28 22 23 23 24 23 27 23 28 24 25 24 27 25 26 25 27 25 30 26 29 27 29 27 30 31 32 31 36 31 37 32 37 33 34 33 35 33 39 3...
output:
349 522
result:
ok single line: '349 522'
Test #6:
score: 0
Accepted
time: 60ms
memory: 378500kb
input:
4 4 1 2 2 4 2 3 3 4
output:
0 0
result:
ok single line: '0 0'
Test #7:
score: 0
Accepted
time: 643ms
memory: 482832kb
input:
999991 647053 1 2 1 4 1 7 1 8 1 10 2 4 2 9 3 8 3 9 3 11 4 6 6 10 7 9 7 11 8 9 9 10 10 11 12 13 12 15 12 21 13 16 13 19 13 22 14 17 14 19 14 20 15 19 15 22 16 20 17 18 17 19 18 20 19 22 20 21 23 25 23 27 23 28 23 30 24 25 24 31 24 32 25 30 25 31 26 32 26 33 27 30 28 32 29 31 29 32 29 33 30 31 34 37 3...
output:
375 322
result:
ok single line: '375 322'
Test #8:
score: 0
Accepted
time: 608ms
memory: 482860kb
input:
999991 647053 1 8 2 7 2 9 2 11 3 6 4 5 5 7 5 8 5 9 5 10 5 11 6 8 6 10 8 9 8 10 8 11 10 11 12 13 12 16 12 22 13 14 13 15 13 16 15 18 15 20 15 22 16 19 16 20 16 21 17 18 17 20 19 22 20 22 21 22 23 24 23 26 23 28 23 33 24 25 24 30 25 26 25 29 25 33 26 32 26 33 28 29 28 31 28 33 29 33 31 33 32 33 34 36 ...
output:
366 307
result:
ok single line: '366 307'
Test #9:
score: 0
Accepted
time: 67ms
memory: 378576kb
input:
5 5 1 2 2 4 2 3 5 4 3 4
output:
0 1
result:
ok single line: '0 1'
Test #10:
score: 0
Accepted
time: 614ms
memory: 483612kb
input:
999991 705876 1 5 1 9 2 5 2 7 2 8 3 4 5 6 6 7 6 9 6 10 6 11 6 12 7 9 7 11 8 10 9 10 11 12 13 14 13 15 13 16 13 18 13 19 14 17 15 19 15 21 16 21 17 19 18 24 19 20 20 21 21 22 21 23 22 23 23 24 25 28 25 31 25 34 26 31 27 28 27 32 28 29 28 33 28 36 29 32 29 33 29 36 30 35 31 34 31 35 32 34 32 35 37 45 ...
output:
1032 1376
result:
ok single line: '1032 1376'
Test #11:
score: 0
Accepted
time: 600ms
memory: 483552kb
input:
999991 705876 1 7 2 10 2 11 2 12 3 7 3 9 4 5 4 8 4 9 5 7 5 9 6 7 6 9 6 11 7 11 9 10 11 12 13 16 13 17 13 24 14 16 14 24 15 17 15 20 15 24 16 17 16 19 17 20 17 22 17 24 18 20 19 23 20 22 20 23 25 26 25 28 25 35 26 31 27 33 27 35 28 32 29 33 29 35 29 36 30 33 30 34 32 33 32 35 33 35 33 36 34 35 37 38 ...
output:
990 1439
result:
ok single line: '990 1439'
Test #12:
score: 0
Accepted
time: 81ms
memory: 378448kb
input:
6 6 1 4 3 2 4 3 4 6 4 5 4 2
output:
0 0
result:
ok single line: '0 0'
Test #13:
score: 0
Accepted
time: 73ms
memory: 378544kb
input:
7 7 1 6 6 7 6 2 2 5 2 3 2 4 3 4
output:
0 0
result:
ok single line: '0 0'
Test #14:
score: 0
Accepted
time: 79ms
memory: 378464kb
input:
8 8 1 2 2 7 2 8 7 8 5 2 2 3 2 4 5 6
output:
0 0
result:
ok single line: '0 0'
Test #15:
score: 0
Accepted
time: 89ms
memory: 378488kb
input:
12 8 1 2 1 3 2 3 3 4 3 5 4 5 6 5 6 7 5 7 2 7 7 8 2 8
output:
0 0
result:
ok single line: '0 0'
Test #16:
score: 0
Accepted
time: 97ms
memory: 378580kb
input:
5 4 1 2 1 3 2 3 2 4 3 4
output:
0 0
result:
ok single line: '0 0'
Test #17:
score: 0
Accepted
time: 67ms
memory: 378460kb
input:
6 7 1 2 2 7 2 3 3 4 4 5 5 6
output:
0 0
result:
ok single line: '0 0'
Test #18:
score: 0
Accepted
time: 88ms
memory: 378516kb
input:
7 8 1 4 4 5 6 7 6 8 2 4 2 3 6 3
output:
0 1
result:
ok single line: '0 1'
Test #19:
score: 0
Accepted
time: 77ms
memory: 378540kb
input:
7 8 1 2 1 3 1 4 5 6 5 7 5 8 1 5
output:
0 1
result:
ok single line: '0 1'
Test #20:
score: 0
Accepted
time: 83ms
memory: 378480kb
input:
4 4 1 3 1 4 2 4 2 3
output:
0 0
result:
ok single line: '0 0'
Test #21:
score: 0
Accepted
time: 76ms
memory: 378488kb
input:
5 5 1 2 1 5 2 4 4 3 3 5
output:
1 0
result:
ok single line: '1 0'
Test #22:
score: 0
Accepted
time: 73ms
memory: 378552kb
input:
9 12 1 2 1 3 4 5 5 6 7 9 8 9 10 11 10 12 11 12
output:
0 0
result:
ok single line: '0 0'
Test #23:
score: 0
Accepted
time: 67ms
memory: 378648kb
input:
186 228 1 2 1 3 5 6 5 8 9 11 9 12 13 14 13 15 13 16 17 18 18 19 21 23 22 23 25 26 25 27 26 27 29 32 30 31 33 34 33 36 34 35 37 39 37 40 38 39 41 42 41 43 41 44 42 43 45 46 46 48 49 51 50 52 53 54 53 55 54 56 57 60 58 60 61 62 61 64 62 64 65 67 65 68 66 68 69 70 69 71 69 72 70 72 74 75 74 76 77 78 78...
output:
18 4
result:
ok single line: '18 4'
Test #24:
score: 0
Accepted
time: 84ms
memory: 378556kb
input:
3 4 1 2 3 4 3 2
output:
1 0
result:
ok single line: '1 0'
Test #25:
score: 0
Accepted
time: 71ms
memory: 379252kb
input:
5110 5065 1 2 1 3 6 7 6 9 11 13 11 14 16 17 16 18 16 19 21 22 21 25 26 28 26 30 31 32 31 33 31 35 36 39 36 40 41 42 41 44 41 45 46 48 46 49 46 50 51 52 51 53 51 54 51 55 56 57 57 58 61 63 62 63 66 67 66 68 67 68 71 74 72 73 76 77 76 79 77 78 81 83 81 84 82 83 86 87 86 88 86 89 87 88 91 95 92 93 96 9...
output:
142 140
result:
ok single line: '142 140'
Test #26:
score: 0
Accepted
time: 87ms
memory: 378556kb
input:
3 4 1 2 2 3 2 4
output:
0 1
result:
ok single line: '0 1'
Test #27:
score: 0
Accepted
time: 201ms
memory: 405056kb
input:
245745 196512 1 2 1 3 7 8 7 10 13 15 13 16 19 20 19 21 19 22 25 26 25 29 31 33 31 35 37 38 37 39 37 41 43 46 43 47 49 50 49 52 49 53 55 57 55 58 55 59 61 62 61 63 61 64 61 65 67 68 67 72 73 75 73 78 79 80 79 81 79 84 85 88 85 90 91 92 91 94 91 96 97 99 97 100 97 102 103 104 103 105 103 106 103 108 1...
output:
2097 2626
result:
ok single line: '2097 2626'
Test #28:
score: 0
Accepted
time: 69ms
memory: 378580kb
input:
5 6 1 6 2 6 3 6 4 6 5 6
output:
0 1
result:
ok single line: '0 1'
Test #29:
score: 0
Accepted
time: 554ms
memory: 487492kb
input:
999999 841330 1 2 1 3 8 9 8 11 15 17 15 18 22 23 22 24 22 25 29 30 29 33 36 38 36 40 43 44 43 45 43 47 50 53 50 54 57 58 57 60 57 61 64 66 64 67 64 68 71 72 71 73 71 74 71 75 78 79 78 83 85 87 85 90 92 93 92 94 92 97 99 102 99 104 106 107 106 109 106 111 113 115 113 116 113 118 120 121 120 122 120 1...
output:
7646 12754
result:
ok single line: '7646 12754'
Test #30:
score: 0
Accepted
time: 534ms
memory: 484544kb
input:
999992 755307 1 6 2 4 2 5 2 7 3 5 3 7 4 5 4 6 8 9 8 13 9 11 9 12 9 14 10 12 10 14 11 12 11 13 15 17 15 20 16 18 16 19 16 21 17 19 17 21 18 19 18 20 22 23 22 24 22 27 23 25 23 26 23 28 24 26 24 28 25 26 25 27 29 32 29 34 30 32 30 33 30 35 31 33 31 35 32 33 32 34 36 37 36 39 36 41 37 39 37 40 37 42 38...
output:
3532 7627
result:
ok single line: '3532 7627'
Test #31:
score: 0
Accepted
time: 551ms
memory: 484088kb
input:
999994 740684 1 3 1 4 1 5 2 5 2 6 3 4 3 5 3 6 3 7 4 6 4 7 8 9 8 10 8 11 8 12 9 12 9 13 10 11 10 12 10 13 10 14 11 13 11 14 15 20 16 19 16 20 17 18 17 19 17 20 17 21 18 20 18 21 22 23 22 27 23 26 23 27 24 25 24 26 24 27 24 28 25 27 25 28 29 31 29 34 30 33 30 34 31 32 31 33 31 34 31 35 32 34 32 35 36 ...
output:
3201 7345
result:
ok single line: '3201 7345'
Test #32:
score: 0
Accepted
time: 548ms
memory: 483188kb
input:
999992 706979 1 2 1 3 1 7 2 3 3 4 3 5 4 6 5 6 8 11 8 14 9 10 10 11 10 12 11 13 12 13 15 16 15 18 15 21 16 17 17 18 17 19 18 20 19 20 22 24 22 25 22 28 23 24 24 25 24 26 25 27 26 27 29 30 29 31 29 32 29 35 30 31 31 32 31 33 32 34 33 34 36 40 36 42 37 38 38 39 38 40 39 41 40 41 43 44 43 47 43 49 44 45...
output:
2402 4121
result:
ok single line: '2402 4121'
Test #33:
score: 0
Accepted
time: 528ms
memory: 481268kb
input:
999994 646072 1 5 1 7 2 3 2 4 2 6 3 6 4 5 4 7 5 6 8 9 8 12 8 14 9 10 9 11 9 13 10 13 11 12 11 14 12 13 15 17 15 19 15 21 16 17 16 18 16 20 17 20 18 19 18 21 19 20 22 23 22 24 22 26 22 28 23 24 23 25 23 27 24 27 25 26 25 28 26 27 29 32 29 33 29 35 30 31 30 32 30 34 31 34 32 33 32 35 33 34 36 37 36 39...
output:
943 2394
result:
ok single line: '943 2394'
Test #34:
score: 0
Accepted
time: 530ms
memory: 485996kb
input:
999995 753298 1 2 1 6 1 7 2 3 2 5 2 6 3 4 5 7 8 10 8 13 8 14 9 10 9 12 9 13 10 11 12 14 15 16 15 17 15 20 15 21 16 17 16 19 16 20 17 18 19 21 22 25 22 27 22 28 23 24 23 26 23 27 24 25 26 28 29 30 29 32 29 34 29 35 30 31 30 33 30 34 31 32 33 35 36 38 36 39 36 41 36 42 37 38 37 40 37 41 38 39 40 42 43...
output:
3698 7209
result:
ok single line: '3698 7209'
Test #35:
score: 0
Accepted
time: 527ms
memory: 482568kb
input:
999989 688429 1 2 1 3 1 4 1 5 2 3 2 4 2 5 2 6 2 7 3 4 3 6 4 5 4 6 5 7 8 13 9 10 9 11 9 12 9 13 9 14 10 11 10 13 11 12 11 13 12 14 15 16 15 20 16 17 16 18 16 19 16 20 16 21 17 18 17 20 18 19 18 20 19 21 22 24 22 27 23 24 23 25 23 26 23 27 23 28 24 25 24 27 25 26 25 27 26 28 29 30 29 31 29 34 30 31 30...
output:
1310 3756
result:
ok single line: '1310 3756'
Test #36:
score: 0
Accepted
time: 585ms
memory: 481816kb
input:
999993 666330 1 3 1 5 1 6 1 7 2 3 2 4 2 5 2 6 2 7 3 4 3 6 4 6 4 7 5 7 8 9 8 10 8 12 8 13 8 14 9 10 9 11 9 12 9 13 9 14 10 11 10 13 11 13 11 14 12 14 15 18 15 19 15 20 15 21 16 17 16 18 16 19 16 20 16 21 17 18 17 20 18 20 18 21 19 21 22 23 22 25 22 26 22 27 22 28 23 24 23 25 23 26 23 27 23 28 24 25 2...
output:
835 3556
result:
ok single line: '835 3556'
Test #37:
score: 0
Accepted
time: 523ms
memory: 481036kb
input:
999993 641725 1 6 2 3 2 4 2 5 2 6 3 6 4 5 5 6 5 7 8 9 8 13 9 10 9 11 9 12 9 13 10 13 11 12 12 13 12 14 15 17 15 20 16 17 16 18 16 19 16 20 17 20 18 19 19 20 19 21 22 23 22 24 22 27 23 24 23 25 23 26 23 27 24 27 25 26 26 27 26 28 29 32 29 34 30 31 30 32 30 33 30 34 31 34 32 33 33 34 33 35 36 37 36 39...
output:
331 2414
result:
ok single line: '331 2414'
Test #38:
score: 0
Accepted
time: 597ms
memory: 480712kb
input:
999994 629048 1 2 1 3 1 5 1 7 2 3 2 4 2 5 3 4 4 7 5 6 5 7 8 11 8 12 8 14 9 10 9 11 9 12 10 11 11 14 12 13 12 14 15 16 15 18 15 19 15 21 16 17 16 18 16 19 17 18 18 21 19 20 19 21 22 24 22 25 22 26 22 28 23 24 23 25 23 26 24 25 25 28 26 27 26 28 29 30 29 31 29 32 29 33 29 35 30 31 30 32 30 33 31 32 32...
output:
164 2050
result:
ok single line: '164 2050'
Test #39:
score: 0
Accepted
time: 570ms
memory: 482640kb
input:
999999 680225 1 2 1 3 1 6 1 7 2 3 2 4 3 4 3 6 3 7 4 6 4 7 5 6 5 7 8 11 8 13 8 14 9 10 9 11 10 11 10 13 10 14 11 13 11 14 12 13 12 14 15 16 15 18 15 20 15 21 16 17 16 18 17 18 17 20 17 21 18 20 18 21 19 20 19 21 22 24 22 25 22 27 22 28 23 24 23 25 24 25 24 27 24 28 25 27 25 28 26 27 26 28 29 30 29 31...
output:
3578 4667
result:
ok single line: '3578 4667'
Test #40:
score: 0
Accepted
time: 577ms
memory: 483100kb
input:
999994 710822 1 2 1 3 1 5 2 4 2 7 3 6 3 7 4 5 6 7 8 11 8 12 9 11 9 14 10 13 10 14 11 12 13 14 15 16 15 18 15 19 16 18 16 21 17 20 17 21 18 19 20 21 22 24 22 25 22 26 23 25 23 28 24 27 24 28 25 26 27 28 29 30 29 31 29 32 29 33 30 32 30 35 31 34 31 35 32 33 34 35 36 41 37 39 37 42 38 41 38 42 39 40 41...
output:
1590 5625
result:
ok single line: '1590 5625'
Test #41:
score: 0
Accepted
time: 551ms
memory: 481636kb
input:
999999 654864 1 2 1 4 1 6 1 7 2 5 3 5 3 6 3 7 4 7 6 7 8 10 8 11 8 13 8 14 9 12 10 12 10 13 10 14 11 14 13 14 15 16 15 17 15 18 15 20 15 21 16 19 17 19 17 20 17 21 18 21 20 21 22 26 22 27 22 28 23 26 24 26 24 27 24 28 25 28 27 28 29 30 29 33 29 34 29 35 30 33 31 33 31 34 31 35 32 35 34 35 36 38 36 40...
output:
653 1686
result:
ok single line: '653 1686'
Test #42:
score: 0
Accepted
time: 535ms
memory: 484204kb
input:
999994 683298 1 2 1 4 1 7 2 4 2 6 2 7 3 4 3 5 3 7 4 5 4 6 4 7 6 7 8 10 8 11 8 14 9 11 9 13 9 14 10 11 10 12 10 14 11 12 11 13 11 14 13 14 15 16 15 17 15 18 15 21 16 18 16 20 16 21 17 18 17 19 17 21 18 19 18 20 18 21 20 21 22 26 22 28 23 25 23 27 23 28 24 25 24 26 24 28 25 26 25 27 25 28 27 28 29 30 ...
output:
944 4865
result:
ok single line: '944 4865'
Test #43:
score: 0
Accepted
time: 512ms
memory: 480856kb
input:
999994 634011 1 2 1 3 1 6 1 7 2 3 2 4 2 5 2 6 3 4 3 5 3 7 4 6 5 6 6 7 8 11 8 13 8 14 9 10 9 11 9 12 9 13 10 11 10 12 10 14 11 13 12 13 13 14 15 16 15 18 15 20 15 21 16 17 16 18 16 19 16 20 17 18 17 19 17 21 18 20 19 20 20 21 22 24 22 25 22 27 22 28 23 24 23 25 23 26 23 27 24 25 24 26 24 28 25 27 26 ...
output:
256 2136
result:
ok single line: '256 2136'
Test #44:
score: 0
Accepted
time: 565ms
memory: 479816kb
input:
999999 586642 2 3 2 4 2 5 2 7 3 4 3 5 3 6 4 5 4 7 5 6 6 7 8 9 9 10 9 11 9 12 9 14 10 11 10 12 10 13 11 12 11 14 12 13 13 14 15 17 16 17 16 18 16 19 16 21 17 18 17 19 17 20 18 19 18 21 19 20 20 21 22 23 22 24 23 24 23 25 23 26 23 28 24 25 24 26 24 27 25 26 25 28 26 27 27 28 29 32 30 31 30 32 30 33 30...
output:
223 715
result:
ok single line: '223 715'
Test #45:
score: 0
Accepted
time: 510ms
memory: 482320kb
input:
999990 686567 1 3 1 4 1 5 1 6 2 5 2 7 5 7 6 7 8 9 8 10 8 11 8 12 8 13 9 12 9 14 12 14 13 14 15 21 16 19 16 21 19 21 20 21 22 23 22 28 23 26 23 28 26 28 27 28 29 31 29 35 30 33 30 35 33 35 34 35 36 37 36 38 36 42 37 40 37 42 40 42 41 42 43 46 43 49 44 47 44 49 47 49 48 49 50 51 50 53 50 56 51 54 51 5...
output:
931 4522
result:
ok single line: '931 4522'
Test #46:
score: 0
Accepted
time: 511ms
memory: 480760kb
input:
999990 632338 1 2 1 3 1 4 1 5 1 6 1 7 2 7 4 5 4 6 5 7 6 7 9 10 9 14 11 12 11 13 12 14 13 14 15 16 16 17 16 21 18 19 18 20 19 21 20 21 22 24 23 24 23 28 25 26 25 27 26 28 27 28 29 30 29 31 30 31 30 35 32 33 32 34 33 35 34 35 36 39 37 38 37 42 39 40 39 41 40 42 41 42 43 44 43 46 44 45 44 49 46 47 46 4...
output:
151 2420
result:
ok single line: '151 2420'
Test #47:
score: 0
Accepted
time: 510ms
memory: 480200kb
input:
999993 597905 1 2 1 4 1 5 1 6 2 5 2 7 3 6 3 7 4 5 4 7 5 7 6 7 8 10 8 11 8 12 8 13 9 12 9 14 10 13 10 14 11 12 11 14 12 14 13 14 15 16 15 17 15 18 15 19 15 20 16 19 16 21 17 20 17 21 18 19 18 21 19 21 20 21 22 28 23 26 23 28 24 27 24 28 25 26 25 28 26 28 27 28 29 30 29 35 30 33 30 35 31 34 31 35 32 3...
output:
396 361
result:
ok single line: '396 361'
Test #48:
score: 0
Accepted
time: 527ms
memory: 480488kb
input:
999996 615720 1 4 2 3 2 4 2 6 3 5 3 6 5 6 5 7 6 7 8 9 8 11 9 10 9 11 9 13 10 12 10 13 12 13 12 14 13 14 15 17 15 18 16 17 16 18 16 20 17 19 17 20 19 20 19 21 20 21 22 23 22 24 22 25 23 24 23 25 23 27 24 26 24 27 26 27 26 28 27 28 29 33 30 31 30 32 30 34 31 33 31 34 33 34 33 35 34 35 36 37 36 40 37 3...
output:
277 414
result:
ok single line: '277 414'
Test #49:
score: 0
Accepted
time: 533ms
memory: 479572kb
input:
999990 581357 1 4 1 5 1 6 2 3 2 6 3 4 4 5 4 6 5 6 5 7 6 7 8 9 8 11 8 12 8 13 9 10 9 13 10 11 11 12 11 13 12 13 12 14 13 14 15 17 15 18 15 19 15 20 16 17 16 20 17 18 18 19 18 20 19 20 19 21 20 21 22 23 22 24 22 25 22 26 22 27 23 24 23 27 24 25 25 26 25 27 26 27 26 28 27 28 29 35 30 31 30 34 31 32 32 ...
output:
104 179
result:
ok single line: '104 179'
Test #50:
score: 0
Accepted
time: 563ms
memory: 478720kb
input:
999987 538132 1 2 1 3 1 4 2 3 2 4 2 6 2 7 3 4 3 7 4 5 4 7 5 6 5 7 6 7 8 12 9 10 9 11 9 13 9 14 10 11 10 14 11 12 11 14 12 13 12 14 13 14 15 16 15 19 16 17 16 18 16 20 16 21 17 18 17 21 18 19 18 21 19 20 19 21 20 21 22 24 22 26 23 24 23 25 23 27 23 28 24 25 24 28 25 26 25 28 26 27 26 28 27 28 29 30 2...
output:
102 6
result:
ok single line: '102 6'
Test #51:
score: 0
Accepted
time: 89ms
memory: 380520kb
input:
20215 8827 1 2 1 3 1 6 2 5 2 6 3 4 3 5 3 6 3 7 4 5 4 6 4 7 5 6 5 7 6 7 8 11 8 13 9 12 9 13 10 11 10 12 10 13 10 14 11 12 11 13 11 14 12 13 12 14 13 14 15 16 15 18 15 20 16 19 16 20 17 18 17 19 17 20 17 21 18 19 18 20 18 21 19 20 19 21 20 21 22 24 22 25 22 27 23 26 23 27 24 25 24 26 24 27 24 28 25 26...
output:
0 0
result:
ok single line: '0 0'
Test #52:
score: 0
Accepted
time: 71ms
memory: 378508kb
input:
4 5 1 2 2 3 3 4 4 5
output:
0 0
result:
ok single line: '0 0'
Test #53:
score: 0
Accepted
time: 527ms
memory: 479376kb
input:
999996 614440 1 2 1 3 1 4 1 5 1 7 1 8 2 3 2 4 2 6 2 7 3 6 3 7 4 5 4 6 4 8 5 7 9 14 9 15 9 16 10 11 10 12 10 14 10 15 11 14 11 15 12 13 12 14 12 16 13 15 17 18 17 22 17 23 17 24 18 19 18 20 18 22 18 23 19 22 19 23 20 21 20 22 20 24 21 23 25 27 25 30 25 31 25 32 26 27 26 28 26 30 26 31 27 30 27 31 28 ...
output:
38 1247
result:
ok single line: '38 1247'
Test #54:
score: 0
Accepted
time: 535ms
memory: 477876kb
input:
1000000 513824 1 4 2 5 2 8 3 6 4 5 4 6 4 7 4 8 5 6 6 7 6 8 9 10 9 12 10 13 10 16 11 14 12 13 12 14 12 15 12 16 13 14 14 15 14 16 17 19 17 20 18 21 18 24 19 22 20 21 20 22 20 23 20 24 21 22 22 23 22 24 25 26 25 27 25 28 26 29 26 32 27 30 28 29 28 30 28 31 28 32 29 30 30 31 30 32 33 37 34 37 34 40 35 ...
output:
8 0
result:
ok single line: '8 0'
Test #55:
score: 0
Accepted
time: 520ms
memory: 477816kb
input:
999993 491984 1 3 1 7 2 4 2 5 2 6 3 5 3 8 4 6 4 7 5 6 5 7 5 8 6 7 6 8 9 10 9 11 9 15 10 12 10 13 10 14 11 13 11 16 12 14 12 15 13 14 13 15 13 16 14 15 14 16 17 20 17 23 18 20 18 21 18 22 19 21 19 24 20 22 20 23 21 22 21 23 21 24 22 23 22 24 25 26 25 28 25 31 26 28 26 29 26 30 27 29 27 32 28 30 28 31...
output:
7 0
result:
ok single line: '7 0'
Test #56:
score: 0
Accepted
time: 556ms
memory: 478964kb
input:
999993 602296 1 3 1 4 2 3 2 4 2 6 2 7 2 8 3 4 4 7 4 8 5 8 6 7 7 8 9 10 9 11 9 12 10 11 10 12 10 14 10 15 10 16 11 12 12 15 12 16 13 16 14 15 15 16 17 21 18 19 18 20 18 22 18 23 18 24 19 20 20 23 20 24 21 24 22 23 23 24 25 26 25 29 26 27 26 28 26 30 26 31 26 32 27 28 28 31 28 32 29 32 30 31 31 32 33 ...
output:
10 374
result:
ok single line: '10 374'
Test #57:
score: 0
Accepted
time: 521ms
memory: 479644kb
input:
999997 620840 1 2 1 3 1 4 1 5 1 7 2 3 2 4 2 5 2 6 2 7 2 8 3 4 3 6 4 6 4 8 5 6 5 8 9 14 9 15 10 11 10 12 10 13 10 14 10 15 10 16 11 12 11 14 12 14 12 16 13 14 13 16 17 18 17 22 17 23 18 19 18 20 18 21 18 22 18 23 18 24 19 20 19 22 20 22 20 24 21 22 21 24 25 27 25 30 25 31 26 27 26 28 26 29 26 30 26 3...
output:
656 1809
result:
ok single line: '656 1809'
Test #58:
score: 0
Accepted
time: 64ms
memory: 378524kb
input:
5 6 1 2 3 4 5 6 2 3 4 5
output:
1 0
result:
ok single line: '1 0'
Test #59:
score: 0
Accepted
time: 494ms
memory: 478768kb
input:
999992 642852 1 4 1 7 1 8 1 9 2 4 2 5 3 6 4 6 5 6 5 8 5 9 6 8 7 9 8 9 10 12 10 15 10 17 10 18 11 12 11 18 12 17 13 15 13 16 13 17 14 15 14 16 14 18 15 18 19 21 19 23 19 25 19 27 20 22 20 24 20 25 20 27 21 23 21 24 22 25 23 24 23 25 23 26 28 31 28 33 29 32 29 34 29 35 29 36 30 33 31 32 31 33 31 35 32...
output:
123 0
result:
ok single line: '123 0'
Test #60:
score: 0
Accepted
time: 566ms
memory: 479624kb
input:
999990 599994 1 3 1 4 1 6 1 7 1 8 1 9 3 4 3 6 4 7 5 7 5 8 5 9 7 8 7 9 8 9 10 11 10 13 10 18 11 12 11 15 11 18 12 17 13 14 13 15 13 18 14 15 14 18 15 16 15 18 16 17 19 20 19 23 19 25 19 26 20 21 20 23 21 27 22 23 22 24 22 25 22 26 22 27 23 25 23 26 24 26 28 29 28 32 28 33 28 36 29 34 29 35 29 36 30 3...
output:
57 40
result:
ok single line: '57 40'
Test #61:
score: 0
Accepted
time: 87ms
memory: 378464kb
input:
8 9 9 8 6 7 3 2 5 4 1 2 4 3 6 5 7 8
output:
0 0
result:
ok single line: '0 0'
Test #62:
score: 0
Accepted
time: 727ms
memory: 488612kb
input:
999999 1000000 1 560136 2 102142 2 236736 3 309371 3 491463 4 538764 5 470246 6 278170 7 227277 8 673767 9 37182 9 231457 11 414293 11 583390 11 812999 11 868721 11 925233 12 254802 12 517049 12 530488 12 910757 12 943612 13 901211 14 1496 14 802703 15 684146 18 159626 18 209532 18 394262 18 583396 ...
output:
20012 719
result:
ok single line: '20012 719'
Test #63:
score: 0
Accepted
time: 538ms
memory: 546312kb
input:
998991 1414 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1...
output:
0 0
result:
ok single line: '0 0'
Test #64:
score: 0
Accepted
time: 518ms
memory: 552260kb
input:
999999 999999 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 ...
output:
1 0
result:
ok single line: '1 0'
Test #65:
score: 0
Accepted
time: 554ms
memory: 642752kb
input:
999997 749999 1 2 2 3 3 1 2 4 4 5 5 6 6 4 5 7 7 8 8 9 9 7 8 10 10 11 11 12 12 10 11 13 13 14 14 15 15 13 14 16 16 17 17 18 18 16 17 19 19 20 20 21 21 19 20 22 22 23 23 24 24 22 23 25 25 26 26 27 27 25 26 28 28 29 29 30 30 28 29 31 31 32 32 33 33 31 32 34 34 35 35 36 36 34 35 37 37 38 38 39 39 37 38 ...
output:
0 1
result:
ok single line: '0 1'
Test #66:
score: 0
Accepted
time: 569ms
memory: 642892kb
input:
999999 750001 1 2 2 3 3 1 2 4 4 5 5 6 6 4 5 7 7 8 8 9 9 7 8 10 10 11 11 12 12 10 11 13 13 14 14 15 15 13 14 16 16 17 17 18 18 16 17 19 19 20 20 21 21 19 20 22 22 23 23 24 24 22 23 25 25 26 26 27 27 25 26 28 28 29 29 30 30 28 29 31 31 32 32 33 33 31 32 34 34 35 35 36 36 34 35 37 37 38 38 39 39 37 38 ...
output:
0 0
result:
ok single line: '0 0'
Test #67:
score: 0
Accepted
time: 527ms
memory: 499616kb
input:
999997 999998 1 2 1 3 1 4 3 6 5 6 5 7 5 8 7 10 9 10 9 11 9 12 11 14 13 14 13 15 13 16 15 18 17 18 17 19 17 20 19 22 21 22 21 23 21 24 23 26 25 26 25 27 25 28 27 30 29 30 29 31 29 32 31 34 33 34 33 35 33 36 35 38 37 38 37 39 37 40 39 42 41 42 41 43 41 44 43 46 45 46 45 47 45 48 47 50 49 50 49 51 49 5...
output:
1 0
result:
ok single line: '1 0'
Test #68:
score: 0
Accepted
time: 614ms
memory: 490324kb
input:
999915 952300 1 41 1 47 1 72 2 16 2 88 2 95 3 9 3 26 3 91 4 21 4 37 4 85 5 14 5 49 5 88 6 25 7 71 7 74 7 84 8 22 9 34 9 83 10 16 10 90 11 18 12 35 12 52 14 17 14 44 14 72 15 26 15 80 15 83 16 42 17 65 18 29 18 85 19 41 19 74 21 38 22 25 22 37 22 53 23 38 24 39 24 63 24 98 25 64 25 91 26 44 26 55 26 ...
output:
15511 1803
result:
ok single line: '15511 1803'
Test #69:
score: 0
Accepted
time: 569ms
memory: 490960kb
input:
999975 995000 1 359 1 729 1 966 2 263 2 487 4 372 4 391 4 877 5 883 6 248 6 254 6 703 7 141 7 333 8 496 8 602 8 934 9 747 10 283 11 386 11 815 12 954 13 963 14 437 14 891 15 274 15 826 16 56 16 278 16 893 18 247 18 789 18 826 19 409 19 695 20 158 20 624 20 838 20 993 21 289 21 734 22 936 22 938 23 2...
output:
19402 813
result:
ok single line: '19402 813'
Test #70:
score: 0
Accepted
time: 619ms
memory: 490180kb
input:
990495 990000 1 4654 2 553 2 4245 3 2524 3 3264 3 4715 3 5674 3 8204 4 5011 5 2857 5 9071 6 1514 6 5066 6 6536 6 7994 7 827 7 6412 8 7290 9 871 9 1936 9 2124 9 6867 11 8860 12 1347 12 3879 12 8952 13 1635 13 3529 14 3313 14 7551 14 8286 15 307 15 614 15 6202 15 7888 15 7935 16 2070 17 689 18 2352 18...
output:
19786 687
result:
ok single line: '19786 687'
Test #71:
score: 0
Accepted
time: 597ms
memory: 488332kb
input:
999955 909050 1 4 1 13 1 28 1 33 1 36 2 25 3 42 4 16 5 25 7 22 7 24 7 30 7 33 7 40 7 50 8 19 8 27 9 17 9 24 10 19 10 20 10 24 10 37 12 34 13 32 13 36 14 36 15 24 16 20 16 31 17 22 18 24 19 32 19 37 19 43 20 27 20 44 21 27 21 33 24 31 24 36 24 41 25 26 26 44 27 28 27 39 27 40 28 36 28 49 30 37 30 39 ...
output:
11763 2903
result:
ok single line: '11763 2903'
Test #72:
score: 0
Accepted
time: 599ms
memory: 490544kb
input:
999900 990000 1 33 1 290 1 323 1 327 1 341 2 12 2 17 2 46 2 198 3 204 3 256 4 27 4 313 6 236 7 217 9 153 9 431 10 21 10 415 10 419 11 58 12 55 12 128 14 390 15 34 16 240 16 321 17 262 18 231 18 238 19 78 19 130 19 266 19 271 20 203 20 474 20 494 21 25 21 429 22 348 22 484 23 388 23 463 24 209 24 243...
output:
19065 967
result:
ok single line: '19065 967'
Test #73:
score: 0
Accepted
time: 619ms
memory: 490712kb
input:
995995 995000 1 516 1 2254 1 3620 2 3500 3 184 3 917 3 1224 3 3467 3 4653 4 537 5 3604 6 687 6 1559 6 4129 7 462 7 1012 7 2094 7 2665 7 4363 7 4473 8 300 8 307 8 1678 8 2921 8 4070 9 3102 9 4561 11 1749 11 3944 11 4927 12 1479 12 3635 13 492 14 1693 14 2362 14 4867 15 2073 15 2166 15 2186 16 1523 16...
output:
19765 706
result:
ok single line: '19765 706'
Test #74:
score: 0
Accepted
time: 451ms
memory: 557304kb
input:
999905 196061 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6...
output:
0 1
result:
ok single line: '0 1'
Test #75:
score: 0
Accepted
time: 426ms
memory: 557244kb
input:
999905 196061 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6...
output:
0 0
result:
ok single line: '0 0'
Test #76:
score: -100
Wrong Answer
time: 553ms
memory: 583852kb
input:
999995 833331 1 2 2 3 3 4 4 5 5 1 1 833331 6 7 7 8 8 9 9 10 10 6 6 833331 11 12 12 13 13 14 14 15 15 11 11 833331 16 17 17 18 18 19 19 20 20 16 16 833331 21 22 22 23 23 24 24 25 25 21 21 833331 26 27 27 28 28 29 29 30 30 26 26 833331 31 32 32 33 33 34 34 35 35 31 31 833331 36 37 37 38 38 39 39 40 40...
output:
0 1
result:
wrong answer 1st lines differ - expected: '1 0', found: '0 1'