QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#361150 | #8328. A Good Problem | Shorya1835 | AC ✓ | 2ms | 4056kb | C++20 | 29.1kb | 2024-03-22 20:46:03 | 2024-03-22 20:46:06 |
Judging History
answer
#include<iostream>
#include <forward_list>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cctype>
#include <climits>
#include <fstream>
#include <random>
#include<list>
#include<iomanip>
#include<numeric>
#include<map>
#include<bitset>
#include<unordered_map>
#include<string>
#include<set>
#include<stack>
#include<queue>
#include<functional>
#include<deque>
#include<utility>
#include <chrono>
using namespace std::chrono;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
#define ordered_set tree<pi, null_type,less<pi>, rb_tree_tag,tree_order_statistics_node_update>
#define fo(i, a, b) for (ll i = a; i < b; i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define no cout << "No" << "\n"
#define yes cout << "Yes" << "\n"
ll p = 1e9 + 7;
#define mod p
vector<ll> primes;
set<ll> primes_set;
vector<ll> fac;
vector<int> pf;
vector<ll> mob;
vector<ll> phi;
vector<bool> prime;
void sieve(int n)
{
prime.resize(n + 1);
for (int p = 0; p <= n; p++) {
prime[p] = 1;
}
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
for (int p = 2; p <= n; p++)
if (prime[p])
primes.pb(p);
}
void sieve_set(int n)
{
prime.resize(n + 1);
for (int p = 0; p <= n; p++) {
prime[p] = 1;
}
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
for (int p = 2; p <= n; p++)
if (prime[p])
primes_set.insert(p);
}
void sievepf(int n)
{
for (int i = 0; i <= n; ++i) {
pf.pb(0);
}
for (int i = 2; i <= n; ++i) {
if (pf[i] == 0) {
pf[i] = i;
primes.push_back(i);
}
for (int j = 0; i * primes[j] <= n; ++j) {
pf[i * primes[j]] = primes[j];
if (primes[j] == pf[i]) {
break;
}
}
}
}
void mobius(int n) {
sievepf(n);
for (int i = 0; i <= n; ++i) {
mob.pb(0);
}
mob[1] = 1;
for (int i = 2; i <= n; ++i) {
if (pf[i] == i)mob[i] = -1;
else {
if ((i / pf[i]) % pf[i] == 0)mob[i] = 0;
else mob[i] = mob[pf[i]] * mob[i / pf[i]];
}
}
}
ll gcd(ll a, ll b) {
if (a == 0)return b;
else return gcd(b % a, a);
}
inline long long mul(long long x, long long y)
{
return ((x % mod) * 1ll * (y % mod)) % mod;
}
long long binpow(long long a, long long b)
{
long long res = 1;
a %= mod;
while (b > 0) {
if (b & 1)
res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
ll gcd_dio(ll a, ll b, ll& x, ll& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll x1, y1;
ll d = gcd_dio(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return d;
}
ll binpow2(ll a, ll b) {
ll mod1 = mod - 1;
long long res = 1;
while (b > 0) {
if (b & 1)
res = (res * a) % mod1;
a = (a * a) % mod1;
b >>= 1;
}
return res;
}
long long inv(long long x)
{
return binpow(x % mod, mod - 2);
}
long long divide(long long x, long long y)
{
return mul(x, inv(y));
}
inline long long add(long long x, long long y)
{
x %= mod;
y %= mod;
return (x + y) % mod;
}
inline long long sub(long long A, long long B)
{
A = (A - B) % mod;
return (A + mod) % mod;
}
void fact(long long c) {
fac.pb(1);
for (long long i = 1; i <= c; ++i) {
fac.pb(mul(fac[i - 1], i));
}
}
ll fib(ll n) {
ll c[4] = { 1,1,1,0 };
ll ans[4] = { 1,0,0,1 };
ll base[4];
base[0] = c[0];
base[1] = c[1];
base[2] = c[2];
base[3] = c[3];
ll base1[4];
if (n == 0) {
return 0;
}
if (n == 1 || n == 2) {
return 1;
}
n -= 2;
while (n > 0) {
if ((n & 1) == 1) {
base1[0] = ans[0];
base1[1] = ans[1];
base1[2] = ans[2];
base1[3] = ans[3];
ans[0] = add(mul(base1[0], base[0]), mul(base1[1], base[2]));
ans[1] = add(mul(base1[0], base[1]), mul(base1[1], base[3]));
ans[2] = add(mul(base1[2], base[0]), mul(base1[3], base[2]));
ans[3] = add(mul(base1[2], base[1]), mul(base1[3], base[3]));
}
base1[0] = base[0];
base1[1] = base[1];
base1[2] = base[2];
base1[3] = base[3];
base[0] = add(mul(base1[0], base1[0]), mul(base1[1], base1[2]));
base[1] = add(mul(base1[0], base1[1]), mul(base1[1], base1[3]));
base[2] = add(mul(base1[2], base1[0]), mul(base[3], base1[2]));
base[3] = add(mul(base1[2], base1[1]), mul(base1[3], base1[3]));
n >>= 1;
}
return add(ans[0], ans[1]);
}
ll inverse(ll a, ll m)
{
ll x, y;
ll g = gcd_dio(a, m, x, y);
if (g != 1) {
return -1;
}
else {
x = (x % m + m) % m;
return x;
}
}
stack<pair<ll, ll>> s1, s2;
ll getmin() {
ll minimum;
if (s1.empty() || s2.empty())
minimum = s1.empty() ? s2.top().second : s1.top().second;
else
minimum = min(s1.top().second, s2.top().second);
return minimum;
}
void addele(ll new_element) {
ll minimum = s1.empty() ? new_element : min(new_element, s1.top().second);
s1.push({ new_element, minimum });
}
void remove() {
if (s2.empty()) {
while (!s1.empty()) {
ll element = s1.top().first;
s1.pop();
ll minimum = s2.empty() ? element : min(element, s2.top().second);
s2.push({ element, minimum });
}
}
s2.pop();
}
void clears() {
while (!s1.empty())s1.pop();
while (!s2.empty())s2.pop();
}
stack<pair<ll, ll>> s3, s4;
ll getmax() {
ll maximum;
if (s3.empty() || s4.empty())
maximum = s3.empty() ? s4.top().second : s3.top().second;
else
maximum = max(s3.top().second, s4.top().second);
return maximum;
}
void addele1(ll new_element) {
ll maximum = s3.empty() ? new_element : max(new_element, s3.top().second);
s3.push({ new_element, maximum });
}
void remove1() {
if (s4.empty()) {
while (!s3.empty()) {
ll element = s3.top().first;
s3.pop();
ll maximum = s4.empty() ? element : max(element, s4.top().second);
s4.push({ element, maximum });
}
}
s4.pop();
}
void clears1() {
while (!s3.empty())s3.pop();
while (!s4.empty())s4.pop();
}
vl dsu(1);
vector<list<ll>> dsuset(1);
// first value in list contains size of list
void addset(ll x) {
dsuset.pb(list<ll>({ 1,x }));
dsu.pb(x);
}
int getset(int x) {
if (dsu[x] == x)return x;
else return getset(dsu[x]);
}
void joinset(int x, int y) {
int a = getset(x);
int b = getset(y);
if (a != b) {
if (*dsuset[a].begin() < *dsuset[b].begin()) {
swap(x, y);
swap(a, b);
}
// x has bigger size set
dsu[b] = a;
*dsuset[a].begin() += *dsuset[b].begin();
dsuset[b].erase(dsuset[b].begin());
dsuset[a].splice(dsuset[a].end(), dsuset[b]);
}
}
vector<ll> dist;
vector<bool> vis;
// make sure that vis is clear before using it again and resize it
vector<vi> edges;
// resize edges
void bfs_dist(int n, int k) {
dist.clear();
dist.resize(n + 1);
int a;
queue<int> d;
d.push(k);
while (!d.empty()) {
a = d.front();
d.pop();
vis[a] = 1;
fo(i, 0, edges[a].size()) {
if (vis[edges[a][i]] == 0) {
d.push(edges[a][i]);
dist[edges[a][i]] = dist[a] + 1;
}
}
}
}
//requires dist amd edges to be cleared and resized, intial call is (Root,root,root,0)
void dfs_shortdis(int k, int a, int p, int dep) {
dist[a] = dep;
for (auto x : edges[a]) {
if (x != p) {
dfs_shortdis(k, x, a, dep + 1);
}
}
}
void bfs_shortdis(int n, int k) {
//shortest distance for unweighted graphs from source node,complexity-O(V+E)
dist.clear();
dist.resize(n + 1, 1e9);
int a;
queue<int> d;
d.push(k);
vis[k] = 1;
dist[k] = 0;
while (!d.empty()) {
a = d.front();
d.pop();
fo(i, 0, edges[a].size()) {
if (vis[edges[a][i]] == 0) {
vis[edges[a][i]] = 1;
d.push(edges[a][i]);
}
if (dist[edges[a][i]] > dist[a] + 1) {
dist[edges[a][i]] = dist[a] + 1;
}
}
}
}
void dfs(int k) {
// template for recursuve dfs functions
vis[k] = 1;
fo(i, 0, edges[k].size()) {
if (vis[edges[k][i]] == 0) {
dfs(edges[k][i]);
}
}
}
void dfs_graph(int n) {
//template to apply dfs to more than 1 connected component graphs
fo(i, 1, n + 1) {
if (!vis[i]) {
dfs(i);
}
}
}
vi child;
// clear and resize child before reuse
void dfs_child(int k) {
//returns number of nodes below a node in a tree
vis[k] = 1;
child[k] = 1;
fo(i, 0, edges[k].size()) {
if (vis[edges[k][i]] == 0) {
dfs_child(edges[k][i]);
child[k] += child[edges[k][i]];
}
}
}
vector<vi> ancestor;
void dfs_k_ances(int k) {
//forms array for kth ancestor and also gives depth array
// also resize and clear dist and flatten and node_first before use
// also build tree flatten array
vis[k] = 1;
if (!ancestor[k].empty()) {
int i = 0;
while (ancestor[ancestor[k][i]].size() >= (i + 1)) {
ancestor[k].pb(ancestor[ancestor[k][i]][i]);
i++;
}
}
fo(i, 0, edges[k].size()) {
if (vis[edges[k][i]] == 0) {
ancestor[edges[k][i]].pb(k);
dist[edges[k][i]] = dist[k] + 1;
dfs_k_ances(edges[k][i]);
}
}
}
int get_kth_ances(int a, int k) {
// call dfs_k_ances beforehand, returns -1 if no kth ancestor
stack<int> d;
int q = 0;
while (k > 0) {
if (k & 1) {
d.push(q);
}
q++;
k >>= 1;
}
q = a;
while (!d.empty()) {
if (ancestor[q].size() >= (d.top() + 1)) {
q = ancestor[q][d.top()];
}
else {
q = -1;
break;
}
d.pop();
}
return q;
}
int lca(int a, int b) {
// call dfs_k_ances beforehand
if (dist[a] > dist[b])swap(a, b);
b = get_kth_ances(b, dist[b] - dist[a]);
if (a == b)return a;
int k = -1, l = dist[a];
while (l > 0) {
l >>= 1;
k++;
}
int at = -2, bt = -1;
for (int i = k; i >= 0; --i) {
if (ancestor[a].size() >= (i + 1))at = ancestor[a][i];
if (ancestor[b].size() >= (i + 1))bt = ancestor[b][i];
if (at != bt)a = at, b = bt;
}
return ancestor[a][0];
}
vi flatten;
vi node_first;// first occurance of node in flatten
vi node_last;
int timer = 0;
// needs only edges to be filled
void euler_dfs(int k) {
// k is root
vis[k] = 1;
node_first[k] = timer++;
flatten.pb(k);
for (auto x : edges[k]) {
if (!vis[x]) {
euler_dfs(x);
flatten.pb(k);
timer++;
}
}
}
vector<vector<pi>> lef, rig;
void buildsparse(int n, int root) {
// n is no of vertices
vl f(22);
f[0] = 1;
fo(i, 1, 22)f[i] = f[i - 1] * 2;
vis.clear();
vis.resize(n + 1);
dist.clear();
dist.resize(n + 1);
node_first.clear();
node_first.resize(n + 1);
timer = 0;
euler_dfs(root);
dfs_shortdis(root, root, root, 0);
lef.clear();
rig.clear();
ll m = flatten.size();
lef.resize(m, vector<pi>(ceil(log2(m)) + 1, mp(1e9, 0)));
rig.resize(m, vector<pi>(ceil(log2(m)) + 1, mp(1e9, 0)));
fo(i, 0, ceil(log2(m)) + 1) {
if (i == 0) {
fo(j, 0, m)lef[j][i] = mp(dist[flatten[j]], flatten[j]);
}
else {
fo(j, 0, m)if (j + f[i - 1] < m)lef[j][i] = min(lef[j][i - 1], lef[j + f[i - 1]][i - 1]);
}
}
fo(i, 0, ceil(log2(m)) + 1) {
if (i == 0) {
fo(j, 0, m)rig[j][i] = mp(dist[flatten[j]], flatten[j]);
}
else {
for (ll j = m - 1; j >= 0; --j)if (j >= f[i - 1])rig[j][i] = min(rig[j][i - 1], rig[j - f[i - 1]][i - 1]);
}
}
}
int lcacon(ll a, ll b) {
// make sure to call buildsparse before using this
ll x = log2(abs(node_first[a] - node_first[b]) + 1);
if (node_first[a] <= node_first[b]) {
return min(lef[node_first[a]][x], rig[node_first[b]][x]).S;
}
else {
return min(lef[node_first[b]][x], rig[node_first[a]][x]).S;
}
}
vector<vector<pair<int, ll>>> edges_weight;
//clear and resize edges_weight before using dijkstra and if source is not connected to ith node then dist is 4*1e18
void dijkstra(int n, int k) {
// result in dist
dist.clear();
dist.resize(n + 1, 4 * 1e18);
vis.clear();
vis.resize(n + 1);
dist[k] = 0;
priority_queue<pair<ll, int>> q;
q.push(mp(0, k));
int a;
while (!q.empty()) {
a = q.top().second;
q.pop();
if (vis[a] == 1)continue;
vis[a] = 1;
for (auto x : edges_weight[a]) {
if (!vis[x.F]) {
if (dist[x.first] > dist[a] + x.second && dist[a] != 4 * 1e18) {
dist[x.F] = dist[a] + x.second;
q.push(mp(-dist[x.F], x.first));
}
}
}
}
}
vector<vector<ll>> dist_all;
bool negative_cycle = 0;
// only need to resize edges_weight for this function,if no path from i to j then then dist_all[i][j] is 4*1e18
void floyd_warsh(int n) {
// result in dist_alland also in bool of negative_cycle
dist_all.clear();
dist_all.resize(n + 1, vector<ll>((n + 1), 4 * 1e18));
fo(i, 1, n + 1) {
for (auto x : edges_weight[i]) {
dist_all[i][x.first] = min(dist_all[i][x.first], x.second);
}
}
fo(i, 1, n + 1)dist_all[i][i] = 0;
fo(k, 1, n + 1) {
fo(i, 1, n + 1) {
fo(j, 1, n + 1) {
dist_all[i][j] = min(dist_all[i][k] + dist_all[k][j], dist_all[i][j]);
}
}
}
// loop to detect negative cycle
fo(i, 1, n + 1) {
if (dist_all[i][i] < 0) {
negative_cycle = 1;
}
}
}
// needs edges_weight to be clear and resized
void bellman_ford(int n, int k) {
// result in dist and also in bool of negative_cycle
dist.clear();
dist.resize(n + 1, 4 * 1e18);
bool v;
dist[k] = 0;
fo(i, 0, n - 1) {
v = 0;
fo(j, 1, n + 1) {
for (auto x : edges_weight[j]) {
if (dist[x.first] > dist[j] + x.S) {
dist[x.F] = dist[j] + x.second;
v = 1;
}
}
}
if (!v) {
// no relaxation in a round
break;
}
}
// last loop to detect negative cycle
fo(j, 1, n + 1) {
for (auto x : edges_weight[j]) {
if (dist[x.first] > dist[j] + x.S) {
dist[x.F] = dist[j] + x.second;
negative_cycle = 1;
}
}
}
}
vi topo_sorted;
void topo_sort(int n) {
// needs edges vector
// stores result of topo sort in topo_sorted
vi a(n + 1);
queue<int> d;
fo(i, 1, n + 1) {
for (auto x : edges[i]) {
a[x] += 1;
}
}
fo(i, 1, n + 1) {
if (a[i] == 0)d.push(i);
}
while (!d.empty()) {
topo_sorted.pb(d.front());
for (auto x : edges[d.front()]) {
if (a[x] == 1)d.push(x);
a[x] -= 1;
}
d.pop();
}
}
// nothing to resize for this func not even edges_weight
vector<pair<pi, ll>> edges1;
vector<vector<pair<int, ll>>> edges_mintree;
void kruskal(int n, int m) {
// n is no of vertices and m is no of edges
// puts edges of min spanning tree in edges_mintree
// returns -1 if no spanning tree i.e. graph has > 1 connected components
edges_mintree.clear();
edges_mintree.resize(n + 1);
dsuset.clear();
dsu.clear();
dsuset.resize(1);
dsu.resize(1);
fo(i, 1, n + 1) {
addset(i);
}
priority_queue<pair<ll, pi>> q;
ll a, b, c;
for (auto x : edges1) {
a = x.F.first;
b = x.first.second;
c = x.second;
q.push(mp(-c, mp(a, b)));
}
pair<ll, pi> x;
while (!q.empty()) {
x = q.top();
x.first = -x.first;
if (getset(x.second.F) != getset(x.second.S)) {
joinset(x.second.first, x.second.S);
edges_mintree[x.second.F].pb(mp(x.second.S, x.F));
}
q.pop();
}
}
// needs edges creates scc of components in dsu
stack<int> finished;
vector<vi> edges_rev;
vector<int> comp;
int compno;
void dfs_scc(int k) {
vis[k] = 1;
for (auto x : edges[k]) {
if (!vis[x])dfs_scc(x);
}
finished.push(k);
}
void dfs_scc2(int k, int j) {
vis[k] = 1;
comp[k] = j;
for (auto x : edges_rev[k]) {
if (!vis[x]) {
joinset(x, k);
dfs_scc2(x, j);
}
}
}
void kosaraju(int n) {
vis.clear();
vis.resize(n + 1);
dsuset.clear();
dsu.clear();
dsuset.resize(1);
dsu.resize(1);
comp.clear();
comp.resize(n + 1);
fo(i, 1, n + 1) {
addset(i);
}
int a;
compno = 0;
fo(i, 1, n + 1) {
if (!vis[i]) {
dfs_scc(i);
}
}
vis.clear();
vis.resize(n + 1);
edges_rev.clear();
edges_rev.resize(n + 1);
fo(i, 1, n + 1) {
for (auto x : edges[i]) {
edges_rev[x].pb(i);
}
}
while (!finished.empty()) {
a = finished.top();
finished.pop();
if (!vis[a])dfs_scc2(a, compno++);
}
}
bool solvable = 1;
vector<bool> solution;
void sat2_solve(int n) {
// ith variable negation is (n+i)th variable
fo(i, 1, n + 1) {
if (comp[i] == comp[n + i]) {
solvable = 0;
break;
}
}
solution.clear();
solution.resize(n + 1);
if (solvable) {
fo(i, 1, n + 1) {
if (comp[i] < comp[n + i]) {
solution[i] = 0;
}
else {
solution[i] = 1;
}
}
}
}
//Normal segment tree for associative operations on a position(both works),(point update,range/point query)
// mass for associative and commutative operations on segment(add to prev i.e. order is not important),(range update,range/point query)
// lazy for associative operations on segment(assignment and matrix mul i.e. order is important),(range update,range/point query)
vector<ll> segtree;
// stores segtree
vector<ll> segarray;
// input array for segtree
long long operation(ll a, ll b) {
return a + b;
}
void build(int v, int tl, int tr) {
// resize segtree before use and resize and take input in segarray
// inital call is build(1,0,n-1)
if (tl == tr) {
segtree[v] = segarray[tl];
}
else {
build(2 * v, tl, (tl + tr) / 2);
build(2 * v + 1, (tl + tr) / 2 + 1, tr);
segtree[v] = operation(segtree[2 * v], segtree[2 * v + 1]);
}
}
ll query(int v, int tl, int tr, int l, int r) {
// call it as (1,0,n-1,l,r)
if (l > r) {
// in case of min keep this as LLONG_MAX but 0 in case of sum and -LLONG_max in case of max
return 0;
}
if (l == tl && r == tr) {
return segtree[v];
}
int tm = (tl + tr) / 2;
return operation(query(2 * v, tl, tm, l, min(r, tm)), query(2 * v + 1, tm + 1, tr, max(l, tm + 1), r));
}
void update(int v, int tl, int tr, int pos, ll new_val) {
// doesnt change segarray
// call it as (1,0,n-1,pos,new_val)
if (tl == tr) {
segtree[v] = operation(segtree[v], new_val);
}
else {
int tm = (tl + tr) / 2;
if (pos <= tm) {
update(2 * v, tl, tm, pos, new_val);
}
else {
update(2 * v + 1, tm + 1, tr, pos, new_val);
}
segtree[v] = operation(segtree[2 * v], segtree[2 * v + 1]);
}
}
long long operation_m(ll a, ll b) {
return a + b;
}
void update_m(int v, int tl, int tr, int l, int r, ll val) {
// call it as (1,0,n-1,l,r,val)
if (l <= r) {
if (l == tl && r == tr) {
segtree[v] = operation_m(segtree[v], val);
}
else {
int tm = (tl + tr) / 2;
update_m(2 * v, tl, tm, l, min(r, tm), val);
update_m(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, val);
}
}
}
ll query_m(int v, int tl, int tr, int pos) {
// doesnt change segarray
// call it as (1,0,n-1,pos)
if (tl == tr) {
return segtree[v];
}
else {
int tm = (tl + tr) / 2;
if (pos <= tm) {
return operation_m(segtree[v], query_m(2 * v, tl, tm, pos));
}
else {
return operation_m(segtree[v], query_m(2 * v + 1, tm + 1, tr, pos));
}
}
}
vector<bool> marked;
void push(int v) {
if (marked[v]) {
segtree[2 * v] = segtree[v];
segtree[2 * v + 1] = segtree[v];
marked[2 * v] = 1;
marked[2 * v + 1] = 1;
marked[v] = 0;
}
}
// size of marked is same as as segtree
void update_l(int v, int tl, int tr, int l, int r, ll val) {
// call it as (1,0,n-1,l,r,val)
if (l <= r) {
if (l == tl && r == tr) {
segtree[v] = val;
marked[v] = 1;
}
else {
push(v);
int tm = (tl + tr) / 2;
update_l(2 * v, tl, tm, l, min(r, tm), val);
update_l(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, val);
}
}
}
ll query_l(int v, int tl, int tr, int pos) {
// doesnt change segarray
// call it as (1,0,n-1,pos)
if (tl == tr) {
return segtree[v];
}
else {
push(v);
int tm = (tl + tr) / 2;
if (pos <= tm) {
return query_l(2 * v, tl, tm, pos);
}
else {
return query_l(2 * v + 1, tm + 1, tr, pos);
}
}
}
// range update range queries
vector<pair<ll, ll>> segt;
// F is min and S is added value
// operation_r is the operation you query for and operation_r1 is the operation you update for
long long operation_r(ll a, ll b) {
return (a & b);
}
long long operation_r1(ll a, ll b) {
return (a | b);
}
void build_r(int v, int tl, int tr) {
// resize segtree before use and resize and take input in segarray
// inital call is build(1,0,n-1)
if (tl == tr) {
segt[v].F = segarray[tl];
}
else {
build_r(2 * v, tl, (tl + tr) / 2);
build_r(2 * v + 1, (tl + tr) / 2 + 1, tr);
segt[v].F = operation_r(segt[2 * v].F, segt[2 * v + 1].F);
}
}
void update_r(int v, int tl, int tr, int l, int r, ll val) {
// call it as (1,0,n-1,l,r,val)
if (l <= r) {
if (l == tl && r == tr) {
segt[v].S = operation_r1(segt[v].S, val);
segt[v].F = operation_r1(segt[v].F, val);
}
else {
int tm = (tl + tr) / 2;
update_r(2 * v, tl, tm, l, min(r, tm), val);
update_r(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, val);
segt[v].F = operation_r1(segt[v].S, operation_r(segt[2 * v].F, segt[2 * v + 1].F));
}
}
}
ll query_r(int v, int tl, int tr, int l, int r) {
// doesnt change segarray
// call it as (1,0,n-1,pos)
if (l > r) {
return LLONG_MAX;
// dont forget to change this for different operations
}
else {
if (l == tl && r == tr) {
return segt[v].F;
}
else {
int tm = (tl + tr) / 2;
return operation_r1(segt[v].S, operation_r(query_r(2 * v, tl, tm, l, min(r, tm)), query_r(2 * v + 1, tm + 1, tr, max(l, tm + 1), r)));
}
}
}
// range update range query but lazy
// operation_rl is the operation you query for
long long operation_rl(ll a, ll b) {
return a + b;
}
void push_r(int v) {
if (marked[v]) {
segt[2 * v].S = segt[v].S;
segt[2 * v + 1].S = segt[v].S;
segt[2 * v].F = segt[v].S;
segt[2 * v + 1].F = segt[v].S;
marked[2 * v] = 1;
marked[2 * v + 1] = 1;
marked[v] = 0;
}
}
void build_rl(int v, int tl, int tr) {
// resize segt and marked before use and resize and take input in segarray
// inital call is build(1,0,n-1)
if (tl == tr) {
segt[v].F = segarray[tl];
}
else {
build_rl(2 * v, tl, (tl + tr) / 2);
build_rl(2 * v + 1, (tl + tr) / 2 + 1, tr);
segt[v].F = operation_rl(segt[2 * v].F, segt[2 * v + 1].F);
}
}
void update_rl(int v, int tl, int tr, int l, int r, ll val) {
// call it as (1,0,n-1,l,r,val)
if (l <= r) {
if (l == tl && r == tr) {
segt[v].S = val;
segt[v].F = val;
marked[v] = 1;
}
else {
push_r(v);
int tm = (tl + tr) / 2;
update_rl(2 * v, tl, tm, l, min(r, tm), val);
update_rl(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, val);
segt[v].F = operation_rl(segt[2 * v].F, segt[2 * v + 1].F);
}
}
}
ll query_rl(int v, int tl, int tr, int l, int r) {
if (l > r) {
return 0;
// dont forget to change this for different operations
}
else {
if (l == tl && r == tr) {
return segt[v].F;
}
else {
push_r(v);
int tm = (tl + tr) / 2;
return operation_rl(query_rl(2 * v, tl, tm, l, min(r, tm)), query_rl(2 * v + 1, tm + 1, tr, max(l, tm + 1), r));
}
}
}
// when using structs make sure to use a intializer, check for nulls, and pass the address to root in a function
const int MAX_ASCII = 2;
int len = 30;
struct vert {
int count = 0;
vert* childs[MAX_ASCII] = { nullptr };
};
vector<string> st;
void trie_build(vert* root) {
// needs list of bit strings in st
fo(i, 0, st.size()) {
vert* start = root;
fo(j, 0, st[i].size()) {
if (start->childs[int(st[i][j]) - 48] == nullptr) {
start->childs[int(st[i][j]) - 48] = new vert();
}
start = start->childs[int(st[i][j]) - 48];
start->count += 1;
}
}
}
void add(string s, vert* root) {
vert* start = root;
fo(i, 0, s.size()) {
if (start->childs[int(s[i]) - 48] == nullptr) {
start->childs[int(s[i]) - 48] = new vert();
start->childs[int(s[i]) - 48]->count = 0;
}
start = start->childs[int(s[i]) - 48];
start->count += 1;
}
}
void remove(string s, vert* root) {
// assuming it already exists
vert* start = root;
fo(i, 0, s.size()) {
vert* x = start->childs[int(s[i]) - 48];
if (x->count == 1)start->childs[int(s[i]) - 48] = nullptr;
swap(start, x);
if (x->count == 0 && x != root)delete x;
start->count -= 1;
}
}
string query_string(string s, vert* root) {
vert* start = root;
string ans = "";
fo(i, 0, s.size()) {
if (start->childs[int(s[i]) - 48] == nullptr) {
start = start->childs[1 - (int(s[i]) - 48)];
ans += char(97 - int(s[i]));
}
else {
start = start->childs[int(s[i]) - 48];
ans += s[i];
}
}
return ans;
}
queue<pi> d;
vector<vi> c;
void merge(int l, int r) {
if (r > l) {
int m = (r + l) / 2;
fo(i, m + 1, r+1) {
for (auto x : c[i]) {
d.push(mp(2, x));
}
}
fo(i, l+1, m+1) {
d.push(mp(1, i));
}
merge(m+1,r);
merge(l, m);
}
}
int main() {
#ifndef ONLINE_JUDGE
clock_t tm = clock();
#endif
/*#ifdef ONLINE_JUDGE
ifstream cin("input.txt");
ofstream cout("output.txt");
#endif*/
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vi b(n);
c.resize(n + 1);
fo(i, 0, n)cin >> b[i];
fo(i, 0, n) {
c[b[i]].pb(i + 1);
}
merge(0, n);
cout << d.size() << "\n";
while (!d.empty()) {
cout << d.front().first << " " << d.front().second << "\n";
d.pop();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3736kb
input:
4 2 4 3 1
output:
8 2 3 2 2 1 1 1 2 2 2 2 1 1 1 2 4
result:
ok Correct!
Test #2:
score: 0
Accepted
time: 1ms
memory: 3928kb
input:
10 4 3 7 3 6 6 10 0 10 9
output:
28 2 5 2 6 2 3 2 10 2 7 2 9 1 1 1 2 1 3 1 4 1 5 2 10 2 7 2 9 1 7 1 8 2 7 2 9 1 7 2 3 2 2 2 4 2 1 1 1 1 2 1 4 2 1 1 1
result:
ok Correct!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
10 6 3 3 9 1 2 4 6 9 7
output:
26 2 1 2 8 2 10 2 4 2 9 1 1 1 2 1 3 1 4 1 5 2 4 2 9 1 7 1 8 1 7 2 10 2 2 2 3 2 7 1 1 1 2 1 4 2 7 2 6 1 1 2 5
result:
ok Correct!
Test #4:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
10 2 9 4 6 8 10 6 9 7 7
output:
30 2 4 2 7 2 9 2 10 2 5 2 2 2 8 2 6 1 1 1 2 1 3 1 4 1 5 2 2 2 8 2 6 1 7 1 8 2 6 2 5 1 7 2 9 2 10 2 3 1 1 1 2 1 4 2 3 2 1 1 1
result:
ok Correct!
Test #5:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
10 1 2 4 7 3 1 3 6 9 1
output:
25 2 8 2 4 2 9 1 1 1 2 1 3 1 4 1 5 2 9 1 7 1 8 1 7 2 4 2 5 2 7 2 3 1 1 1 2 1 4 2 3 2 2 1 1 2 1 2 6 2 10
result:
ok Correct!
Test #6:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
10 4 4 8 3 6 1 2 3 2 3
output:
25 2 5 2 3 1 1 1 2 1 3 1 4 1 5 1 7 1 8 2 3 1 7 2 4 2 8 2 10 2 1 2 2 1 1 1 2 1 4 2 1 2 2 2 7 2 9 1 1 2 6
result:
ok Correct!
Test #7:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
10 4 3 1 8 4 6 1 1 2 8
output:
26 2 6 2 4 2 10 1 1 1 2 1 3 1 4 1 5 1 7 1 8 2 4 2 10 1 7 2 2 2 1 2 5 1 1 1 2 1 4 2 1 2 5 2 9 1 1 2 3 2 7 2 8
result:
ok Correct!
Test #8:
score: 0
Accepted
time: 1ms
memory: 3756kb
input:
100 13 66 98 73 11 2 65 56 61 30 91 83 90 84 64 44 22 21 93 7 41 46 41 18 13 23 80 20 45 32 54 35 90 52 7 44 4 8 38 13 67 14 5 35 70 15 30 72 58 31 36 40 32 43 52 76 78 27 43 42 80 78 64 43 10 23 61 2 3 19 4 47 76 79 10 89 83 9 40 37 36 35 79 19 46 24 23 5 1 100 22 55 37 24 74 75 31 48 79 87
output:
556 2 34 2 55 2 31 2 92 2 8 2 49 2 9 2 67 2 15 2 63 2 7 2 2 2 41 2 45 2 48 2 4 2 95 2 96 2 56 2 73 2 57 2 62 2 74 2 83 2 99 2 27 2 61 2 12 2 77 2 14 2 100 2 76 2 13 2 33 2 11 2 19 2 3 2 90 1 1 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 ...
result:
ok Correct!
Test #9:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
100 12 84 19 6 50 64 72 49 6 11 62 23 35 54 41 68 77 16 88 11 19 52 25 7 79 27 68 42 86 74 25 40 44 5 30 95 36 18 83 23 47 86 69 18 100 52 0 21 94 2 92 68 23 44 41 6 17 50 93 13 30 25 66 59 21 63 7 82 51 20 70 29 99 76 50 88 54 5 26 28 10 100 92 79 55 57 92 21 55 59 82 60 49 22 13 14 69 62 13 12
output:
578 2 69 2 22 2 46 2 14 2 77 2 85 2 89 2 86 2 64 2 90 2 92 2 11 2 98 2 66 2 6 2 63 2 16 2 27 2 52 2 43 2 97 2 71 2 7 2 30 2 74 2 17 2 25 2 84 2 68 2 91 2 39 2 2 2 29 2 42 2 19 2 76 2 51 2 83 2 87 2 59 2 49 2 36 2 73 2 45 2 82 1 1 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 1...
result:
ok Correct!
Test #10:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
100 57 58 65 22 1 8 7 53 29 91 39 85 30 88 54 11 46 12 0 85 86 80 17 59 13 86 39 89 13 48 21 45 45 61 49 60 3 31 73 94 31 44 25 87 8 35 83 38 69 73 0 51 86 68 71 70 23 12 97 70 12 28 77 42 93 55 13 85 42 42 52 94 24 0 1 6 14 37 66 41 98 49 82 46 36 10 30 98 56 98 38 73 45 17 6 99 18 90 99 39
output:
571 2 52 2 71 2 8 2 15 2 66 2 89 2 1 2 2 2 24 2 36 2 34 2 3 2 79 2 54 2 49 2 56 2 60 2 55 2 39 2 50 2 92 2 63 2 22 2 83 2 47 2 12 2 20 2 68 2 21 2 26 2 53 2 44 2 14 2 28 2 98 2 10 2 65 2 40 2 72 2 59 2 81 2 88 2 90 2 96 2 99 1 1 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...
result:
ok Correct!
Test #11:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
100 12 22 7 50 1 15 38 89 24 39 35 2 98 7 35 40 27 8 43 35 40 51 1 13 13 57 44 5 39 69 81 77 71 28 49 9 21 51 14 22 29 33 18 3 1 86 60 27 67 64 11 22 5 28 35 36 73 52 8 30 86 79 68 53 31 51 14 28 11 3 79 77 31 16 16 48 4 46 72 49 28 17 71 12 61 32 20 27 31 64 75 57 67 21 24 15 74 30 12 12
output:
538 2 22 2 38 2 66 2 58 2 64 2 26 2 92 2 47 2 85 2 50 2 90 2 49 2 93 2 63 2 30 2 33 2 83 2 79 2 57 2 97 2 91 2 32 2 72 2 62 2 71 2 31 2 46 2 61 2 8 2 13 1 1 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...
result:
ok Correct!
Test #12:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
100 28 27 6 9 3 30 63 2 65 50 26 3 77 35 16 14 53 37 26 8 9 60 51 40 10 49 29 13 33 15 35 15 2 24 44 57 42 34 27 54 3 63 53 73 23 36 39 28 86 69 68 41 15 18 24 89 29 47 56 28 14 32 78 11 29 11 59 47 11 25 80 50 30 37 6 61 90 49 27 19 29 46 24 1 32 73 4 28 42 23 3 34 6 12 52 69 7 34 52 15
output:
538 2 23 2 95 2 99 2 17 2 43 2 40 2 59 2 36 2 67 2 22 2 76 2 7 2 42 2 9 2 51 2 50 2 96 2 44 2 86 2 13 2 63 2 71 2 49 2 56 2 77 1 1 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 ...
result:
ok Correct!
Test #13:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
100 25 7 7 9 34 58 34 36 49 6 10 34 22 40 24 17 9 90 54 2 38 67 59 74 31 8 34 15 12 55 12 45 4 19 4 19 28 40 92 4 4 22 21 2 39 71 65 77 11 13 9 37 72 32 21 16 23 39 23 66 16 28 13 41 12 45 66 13 49 45 43 34 16 84 6 6 81 22 4 23 35 3 69 14 15 33 8 71 26 52 9 20 9 46 68 74 50 21 23 35
output:
535 2 90 2 19 2 30 2 6 2 23 2 47 2 60 2 67 2 22 2 95 2 83 2 46 2 88 2 53 2 24 2 96 2 48 2 77 2 74 2 18 2 39 1 1 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...
result:
ok Correct!
Test #14:
score: 0
Accepted
time: 1ms
memory: 4004kb
input:
1000 34 769 740 957 126 724 943 359 299 576 260 460 760 303 348 482 42 335 484 573 302 717 25 356 310 296 235 487 342 362 379 778 964 875 655 60 13 422 136 964 240 675 262 628 805 953 686 20 305 888 982 688 366 105 508 252 971 419 715 945 910 343 835 926 63 59 441 335 322 56 75 335 128 514 839 424 1...
output:
8939 2 103 2 179 2 189 2 831 2 140 2 516 2 875 2 750 2 55 2 490 2 587 2 683 2 834 2 964 2 74 2 104 2 138 2 778 2 967 2 995 2 387 2 669 2 318 2 327 2 697 2 701 2 294 2 589 2 729 2 229 2 307 2 665 2 993 2 439 2 209 2 643 2 679 2 115 2 398 2 791 2 243 2 676 2 857 2 211 2 710 2 552 2 127 2 163 2 114 2 4...
result:
ok Correct!
Test #15:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
1000 668 960 321 884 19 156 939 362 0 202 59 402 991 327 654 803 893 662 85 825 342 200 91 867 199 649 117 64 242 668 887 663 843 105 823 639 904 992 670 315 100 941 662 237 879 900 603 575 240 532 573 310 264 442 925 924 244 634 88 635 685 180 235 178 699 356 366 623 137 24 810 783 174 553 4 767 66...
output:
9008 2 852 2 117 2 334 2 474 2 317 2 425 2 168 2 740 2 925 2 178 2 468 2 473 2 688 2 525 2 729 2 706 2 378 2 769 2 263 2 671 2 713 2 986 2 299 2 204 2 50 2 248 2 631 2 82 2 965 2 904 2 844 2 881 2 536 2 373 2 702 2 760 2 726 2 814 2 839 2 532 2 438 2 786 2 618 2 74 2 207 2 847 2 294 2 484 2 709 2 55...
result:
ok Correct!
Test #16:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
1000 969 408 165 253 331 421 61 882 701 103 489 555 712 547 769 3 619 952 972 451 564 413 293 173 488 217 689 167 114 562 419 638 340 527 348 288 785 610 769 142 753 91 36 215 576 442 762 853 20 911 843 117 741 949 209 694 126 695 389 365 92 657 663 304 277 476 692 87 315 199 33 926 232 514 714 254 ...
output:
8983 2 613 2 482 2 801 2 221 2 230 2 847 2 935 2 240 2 618 2 74 2 396 2 212 2 520 2 251 2 919 2 288 2 723 2 807 2 442 2 921 2 413 2 949 2 34 2 397 2 922 2 509 2 346 2 360 2 192 2 879 2 590 2 854 2 322 2 692 2 933 2 356 2 969 2 224 2 650 2 956 2 14 2 487 2 542 2 804 2 226 2 571 2 282 2 638 2 336 2 44...
result:
ok Correct!
Test #17:
score: 0
Accepted
time: 1ms
memory: 4004kb
input:
1000 203 307 134 54 891 392 567 161 179 563 175 184 863 89 54 537 563 34 97 207 517 286 750 517 195 63 477 468 168 863 338 193 455 120 60 584 135 197 159 667 834 154 533 191 392 142 715 218 96 609 25 492 295 57 347 263 289 359 290 617 146 616 111 528 179 714 910 233 180 251 134 692 365 78 157 386 26...
output:
8426 2 136 2 81 2 848 2 909 2 491 2 796 2 325 2 780 2 160 2 405 2 746 2 147 2 816 2 99 2 494 2 927 2 460 2 285 2 21 2 24 2 98 2 689 2 884 2 999 2 223 2 683 2 793 2 732 2 320 2 703 2 64 2 183 2 635 2 360 2 908 2 859 2 43 2 288 2 213 2 609 2 87 2 16 2 788 2 404 2 956 2 730 2 342 2 913 2 537 2 141 2 38...
result:
ok Correct!
Test #18:
score: 0
Accepted
time: 1ms
memory: 4004kb
input:
1000 359 29 135 514 371 700 67 651 167 555 476 413 215 19 110 225 289 13 46 616 762 42 547 218 26 573 674 109 454 894 215 591 42 13 361 304 128 201 576 392 54 111 425 119 344 260 252 484 51 492 572 207 372 183 745 560 684 294 270 97 278 38 223 282 120 273 630 294 625 752 818 203 417 113 191 811 902 ...
output:
8465 2 541 2 80 2 374 2 387 2 896 2 663 2 306 2 847 2 661 2 695 2 344 2 946 2 117 2 508 2 4 2 886 2 157 2 188 2 296 2 981 2 522 2 516 2 530 2 128 2 138 2 378 2 270 2 445 2 247 2 995 2 551 2 244 2 492 2 412 2 107 2 837 2 688 2 876 2 900 2 23 2 147 2 316 2 953 2 386 2 519 2 132 2 254 2 431 2 10 2 623 ...
result:
ok Correct!
Test #19:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
1000 672 331 438 653 624 242 641 619 51 548 649 796 172 324 106 792 16 147 307 248 86 699 223 11 633 239 340 473 526 145 25 83 13 586 329 97 494 63 279 119 158 103 7 411 44 123 520 597 546 182 90 558 79 1 765 330 285 278 137 464 15 676 171 224 569 493 578 508 206 286 132 41 2 628 93 111 305 15 215 3...
output:
8550 2 608 2 896 2 259 2 953 2 135 2 300 2 765 2 68 2 861 2 170 2 816 2 180 2 535 2 223 2 528 2 632 2 668 2 972 2 671 2 936 2 383 2 981 2 766 2 369 2 47 2 220 2 264 2 573 2 793 2 146 2 29 2 549 2 940 2 945 2 605 2 662 2 424 2 532 2 912 2 392 2 236 2 320 2 287 2 562 2 99 2 186 2 619 2 968 2 49 2 229 ...
result:
ok Correct!
Test #20:
score: 0
Accepted
time: 1ms
memory: 4056kb
input:
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
8987 2 501 2 502 2 503 2 504 2 505 2 506 2 507 2 508 2 509 2 510 2 511 2 512 2 513 2 514 2 515 2 516 2 517 2 518 2 519 2 520 2 521 2 522 2 523 2 524 2 525 2 526 2 527 2 528 2 529 2 530 2 531 2 532 2 533 2 534 2 535 2 536 2 537 2 538 2 539 2 540 2 541 2 542 2 543 2 544 2 545 2 546 2 547 2 548 2 549 2...
result:
ok Correct!
Test #21:
score: 0
Accepted
time: 2ms
memory: 3856kb
input:
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ...
output:
13049 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 6...
result:
ok Correct!
Test #22:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
4049 1 1 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 61...
result:
ok Correct!
Extra Test:
score: 0
Extra Test Passed