QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#658919 | #9482. Count Pseudo-Palindromes | ucup-team087# | AC ✓ | 2383ms | 124448kb | C++23 | 23.6kb | 2024-10-19 17:56:30 | 2024-10-19 17:56:31 |
Judging History
answer
#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
bool dbg=false;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
using vvi=vc<vc<int>>;
template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
return os<<"{"<<p.a<<","<<p.b<<"}";
}
template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
os<<"{";
for(auto e:v)os<<e<<",";
return os<<"}";
}
#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
os<<t<<" ";
dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif
using uint=unsigned;
using ull=unsigned long long;
template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
return os<<vc<t>(all(a));
}
ll rand_int(ll l, ll r) { //[l, r]
//#ifdef LOCAL
static mt19937_64 gen;
/*#else
static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
#endif*/
return uniform_int_distribution<ll>(l, r)(gen);
}
ll rand_int(ll k){ //[0,k)
return rand_int(0,k-1);
}
string rand_string(int n,char lw,char up){
string s(n,'?');
rep(i,n)s[i]=rand_int(lw,up);
return s;
}
int current_run_id,run_batch_size=1000;
int calc_random_limit(){
return current_run_id/run_batch_size+1;
}
template<class t>
void generate_single(t&a){
a=rand_int(1,calc_random_limit());
}
void generate_single(string&a){
int n;generate_single(n);
a=rand_string(n,'a','b');
}
template<class t,class u>
void generate_single(pair<t,u>&a){
generate_single(a.a);
generate_single(a.b);
}
//https://trap.jp/post/1224/
template<class... Args>
void input(Args&... a){
if(dbg){
(generate_single(a),...);
}else{
#ifdef USE_FAST_IO
sc.read(a...);
#else
(cin >> ... >> a);
#endif
}
}
#define INT(...) int __VA_ARGS__;input(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;input(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;input(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;input(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;input(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;input(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;input(__VA_ARGS__)
#define overload3(a,b,c,d,...) d
#define VI2(name,size) vi name(size);rep(i_##name,size)input(name[i_##name]);
#define VI3(name,size,offset) vi name(size);rep(i_##name,size)input(name[i_##name]),name[i_##name]+=offset;
#define VI(...) overload3(__VA_ARGS__,VI3,VI2)(__VA_ARGS__)
#define VPI(name,size) vc<pi> name(size);rep(i_##name,size)input(name[i_##name]);
#define VVI(name,sizeN,sizeM) vvi name(sizeN,vi(sizeM));\
rep(i_##name,sizeN)rep(j_##name,sizeM)input(name[i_##name][j_##name]);
#define VS(name,size) vc<string> name(size);rep(i_##name,size)input(name[i_##name]);
#define overload5(a,b,c,d,e,f,...) f
#define VVC4(type,name,sizeN,sizeM) vvc<type> name(sizeN,vc<type>(sizeM));
#define VVC5(type,name,sizeN,sizeM,ini) vvc<type> name(sizeN,vc<type>(sizeM,ini));
#define VVC(...) overload5(__VA_ARGS__,VVC5,VVC4)(__VA_ARGS__)
template<class T>
T vvvc(T v){
return v;
}
template<class T,class...Args>
auto vvvc(int n,T v,Args...args){
return vector(n,vvvc(v,args...));
}
template<int i,class T>
void print_tuple(ostream&,const T&){
}
template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
if(i)os<<",";
os<<get<i>(t);
print_tuple<i+1,T,Args...>(os,t);
}
template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
os<<"{";
print_tuple<0,tuple<Args...>,Args...>(os,t);
return os<<"}";
}
void printsuc(int suc){
#ifdef USE_FAST_IO
if(suc==1)pr.write('\n');
if(suc==2)pr.write(' ');
#else
if(suc==1){
if(dbg)cout<<endl;
else{
#ifdef LOCAL
cout<<endl;
#else
cout<<"\n";
#endif
}
}
if(suc==2)
cout<<" ";
#endif
}
template<class t>
void print_single(t x,int suc=1){
#ifdef USE_FAST_IO
pr.write(x);
#else
cout<<x;
#endif
printsuc(suc);
}
template<class t,class u>
void print_single(const pair<t,u>&p,int suc=1){
print_single(p.a,2);
print_single(p.b,suc);
}
template<class T>
void print_single(const vector<T>&v,int suc=1){
rep(i,v.size())
print_single(v[i],i==int(v.size())-1?3:2);
printsuc(suc);
}
template<class T,size_t N>
void print_single(const array<T,N>&v,int suc=1){
rep(i,N)
print_single(v[i],i==int(N)-1?3:2);
printsuc(suc);
}
template<class T>
void print(const T&t){
print_single(t);
}
template<class T,class ...Args>
void print(const T&t,const Args&...args){
print_single(t,2);
print(args...);
}
template<class T>
void printvv(const vvc<T>&vs){
for(const auto&row:vs)print(row);
}
string readString(){
string s;
cin>>s;
return s;
}
template<class T>
T sq(const T& t){
return t*t;
}
void YES(bool ex=true){
cout<<"YES\n";
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void NO(bool ex=true){
cout<<"NO\n";
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void Yes(bool ex=true){
cout<<"Yes\n";
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void No(bool ex=true){
cout<<"No\n";
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
//#define CAPITAL
/*
void yes(bool ex=true){
#ifdef CAPITAL
cout<<"YES"<<"\n";
#else
cout<<"Yes"<<"\n";
#endif
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void no(bool ex=true){
#ifdef CAPITAL
cout<<"NO"<<"\n";
#else
cout<<"No"<<"\n";
#endif
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}*/
void possible(bool ex=true){
#ifdef CAPITAL
cout<<"POSSIBLE"<<"\n";
#else
cout<<"Possible"<<"\n";
#endif
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void impossible(bool ex=true){
#ifdef CAPITAL
cout<<"IMPOSSIBLE"<<"\n";
#else
cout<<"Impossible"<<"\n";
#endif
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
constexpr ll ten(int n){
return n==0?1:ten(n-1)*10;
}
const ll infLL=LLONG_MAX/3;
#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif
int topbit(signed t){
return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
return t==0?-1:63-__builtin_clzll(t);
}
int topbit(ull t){
return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
return a==0?64:__builtin_ctzll(a);
}
int botbit(ull a){
return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
return __builtin_popcount(t);
}
int popcount(ll t){
return __builtin_popcountll(t);
}
int popcount(ull t){
return __builtin_popcountll(t);
}
int bitparity(ll t){
return __builtin_parityll(t);
}
bool ispow2(int i){
return i&&(i&-i)==i;
}
ll mask(int i){
return (ll(1)<<i)-1;
}
ull umask(int i){
return (ull(1)<<i)-1;
}
ll minp2(ll n){
if(n<=1)return 1;
else return ll(1)<<(topbit(n-1)+1);
}
bool inc(int a,int b,int c){
return a<=b&&b<=c;
}
template<class S> void mkuni(S&v){
sort(all(v));
v.erase(unique(all(v)),v.ed);
}
template<class t> bool isuni(vc<t> v){
int s=si(v);
mkuni(v);
return si(v)==s;
}
template<class t>
void myshuffle(vc<t>&a){
rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}
template<class S,class u>
int lwb(const S&v,const u&a){
return lower_bound(all(v),a)-v.bg;
}
template<class t,class u>
bool bis(const vc<t>&v,const u&a){
return binary_search(all(v),a);
}
//VERIFY: yosupo
//KUPC2017J
//AOJDSL1A
//without rank
struct unionfind{
vi p,s;
int c;
unionfind(int n):p(n,-1),s(n,1),c(n){}
void clear(){
fill(all(p),-1);
fill(all(s),1);
c=si(p);
}
int find(int a){
return p[a]==-1?a:(p[a]=find(p[a]));
}
//set b to a child of a
bool unite(int a,int b){
a=find(a);
b=find(b);
if(a==b)return false;
p[b]=a;
s[a]+=s[b];
c--;
return true;
}
bool same(int a,int b){
return find(a)==find(b);
}
int sz(int a){
return s[find(a)];
}
};
vvc<int> readGraph(int n,int m){
vvc<int> g(n);
rep(i,m){
int a,b;
cin>>a>>b;
//sc.read(a,b);
a--;b--;
g[a].pb(b);
g[b].pb(a);
}
return g;
}
vvc<int> rand_tree(int n){
vvc<int> t(n);
unionfind uf(n);
while(uf.c>1){
int a=rand_int(n);
int b=rand_int(n);
if(uf.unite(a,b)){
t[a].pb(b);
t[b].pb(a);
}
}
return t;
}
vvc<int> readTree(int n){
if(dbg){
return rand_tree(n);
}else{
return readGraph(n,n-1);
}
}
vi readRooted(int n){
assert(!dbg);
vi par(n,-1);
rng(i,1,n){
input(par[i]);
par[i]--;
assert(inc(0,par[i],i-1));
}
return par;
}
void printTree(const vvc<int> t){
int n=si(t);
int degsum=0;
rep(i,n)degsum+=si(t[i]);
if(degsum==n-1){
//directed
rep(i,si(t))for(auto j:t[i]){
print(i+1,j+1);
}
}else if(degsum==2*(n-1)){
//undirected
rep(i,si(t))for(auto j:t[i])if(i<j){
print(i+1,j+1);
}
}else{
assert(false);
}
}
template<class t>
vc<t> presum(const vc<t>&a){
vc<t> s(si(a)+1);
rep(i,si(a))s[i+1]=s[i]+a[i];
return s;
}
vc<ll> presum(const vi&a){
vc<ll> s(si(a)+1);
rep(i,si(a))s[i+1]=s[i]+a[i];
return s;
}
//BIT で数列を管理するときに使う (CF850C)
template<class t>
vc<t> predif(vc<t> a){
gnr(i,1,si(a))a[i]-=a[i-1];
return a;
}
template<class t>
vvc<ll> imos(const vvc<t>&a){
int n=si(a),m=si(a[0]);
vvc<ll> b(n+1,vc<ll>(m+1));
rep(i,n)rep(j,m)
b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
return b;
}
//verify してないや
void transvvc(int&n,int&m){
swap(n,m);
}
template<class t,class... Args>
void transvvc(int&n,int&m,vvc<t>&a,Args&...args){
assert(si(a)==n);
vvc<t> b(m,vi(n));
rep(i,n){
assert(si(a[i])==m);
rep(j,m)b[j][i]=a[i][j];
}
a.swap(b);
transvvc(n,m,args...);
}
//CF854E
void rotvvc(int&n,int&m){
swap(n,m);
}
template<class t,class... Args>
void rotvvc(int&n,int&m,vvc<t>&a,Args&...args){
assert(si(a)==n);
vvc<t> b(m,vi(n));
rep(i,n){
assert(si(a[i])==m);
rep(j,m)b[m-1-j][i]=a[i][j];
}
a.swap(b);
rotvvc(n,m,args...);
}
//ソートして i 番目が idx[i]
//CF850C
template<class t>
vi sortidx(const vc<t>&a){
int n=si(a);
vi idx(n);iota(all(idx),0);
sort(all(idx),[&](int i,int j){return a[i]<a[j];});
return idx;
}
//vs[i]=a[idx[i]]
//例えば sortidx で得た idx を使えば単にソート列になって返ってくる
//CF850C
template<class t>
vc<t> a_idx(const vc<t>&a,const vi&idx){
int n=si(a);
assert(si(idx)==n);
vc<t> vs(n);
rep(i,n)vs[i]=a[idx[i]];
return vs;
}
//CF850C
vi invperm(const vi&p){
int n=si(p);
vi q(n);
rep(i,n)q[p[i]]=i;
return q;
}
template<class t,class s=t>
s SUM(const vc<t>&a){
return accumulate(all(a),s(0));
}
template<class t,size_t K,class s=t>
s SUM(const array<t,K>&a){
return accumulate(all(a),s(0));
}
template<class t>
t MAX(const vc<t>&a){
return *max_element(all(a));
}
template<class t>
pair<t,int> MAXi(const vc<t>&a){
auto itr=max_element(all(a));
return mp(*itr,itr-a.bg);
}
template<class A>
auto MIN(const A&a){
return *min_element(all(a));
}
template<class t>
pair<t,int> MINi(const vc<t>&a){
auto itr=min_element(all(a));
return mp(*itr,itr-a.bg);
}
vi vid(int n){
vi res(n);iota(all(res),0);
return res;
}
template<class S>
void soin(S&s){
sort(all(s));
}
template<class S,class F>
void soin(S&s,F&&f){
sort(all(s),forward<F>(f));
}
template<class S>
S soout(S s){
soin(s);
return s;
}
template<class S>
void rein(S&s){
reverse(all(s));
}
template<class S>
S reout(S s){
rein(s);
return s;
}
template<class t,class u>
pair<t,u>&operator+=(pair<t,u>&a,pair<t,u> b){
a.a+=b.a;a.b+=b.b;return a;}
template<class t,class u>
pair<t,u>&operator-=(pair<t,u>&a,pair<t,u> b){
a.a-=b.a;a.b-=b.b;return a;}
template<class t,class u>
pair<t,u> operator+(pair<t,u> a,pair<t,u> b){return mp(a.a+b.a,a.b+b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a,pair<t,u> b){return mp(a.a-b.a,a.b-b.b);}
template<class t,class u,class v>
pair<t,u>&operator*=(pair<t,u>&a,v b){
a.a*=b;a.b*=b;return a;}
template<class t,class u,class v>
pair<t,u> operator*(pair<t,u> a,v b){return a*=b;}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a){return mp(-a.a,-a.b);}
namespace std{
template<class t,class u>
istream&operator>>(istream&is,pair<t,u>&a){
return is>>a.a>>a.b;
}
}
template<class t>
t gpp(vc<t>&vs){
assert(si(vs));
t res=move(vs.back());
vs.pop_back();
return res;
}
template<class t,class u>
void pb(vc<t>&a,const vc<u>&b){
a.insert(a.ed,all(b));
}
template<class t,class...Args>
vc<t> cat(vc<t> a,Args&&...b){
(pb(a,forward<Args>(b)),...);
return a;
}
template<class t,class u>
vc<t>& operator+=(vc<t>&a,u x){
for(auto&v:a)v+=x;
return a;
}
template<class t,class u>
vc<t> operator+(vc<t> a,u x){
return a+=x;
}
template<class t>
vc<t>& operator+=(vc<t>&a,const vc<t>&b){
a.resize(max(si(a),si(b)));
rep(i,si(b))a[i]+=b[i];
return a;
}
template<class t>
vc<t> operator+(const vc<t>&a,const vc<t>&b){
vc<t> c(max(si(a),si(b)));
rep(i,si(a))c[i]+=a[i];
rep(i,si(b))c[i]+=b[i];
return c;
}
template<class t,class u>
vc<t>& operator-=(vc<t>&a,u x){
for(auto&v:a)v-=x;
return a;
}
template<class t,class u>
vc<t> operator-(vc<t> a,u x){
return a-=x;
}
template<class t,class u>
vc<t>& operator*=(vc<t>&a,u x){
for(auto&v:a)v*=x;
return a;
}
template<class t,class u>
vc<t> operator*(vc<t> a,u x){
return a*=x;
}
template<class t,class u>
vc<t>& operator/=(vc<t>&a,u x){
for(auto&v:a)v/=x;
return a;
}
template<class t,class u>
vc<t> operator/(vc<t> a,u x){
return a/=x;
}
template<class t>
vc<t>& operator<<=(vc<t>&a,int k){
assert(k>=0);
a.insert(a.bg,k,t(0));
return a;
}
template<class t>
vc<t> operator<<(vc<t> a,int k){
return a<<=k;
}
template<class t>
vc<t>& operator>>=(vc<t>&a,int k){
if(si(a)<=k)a.clear();
else a.erase(a.bg,a.bg+k);
return a;
}
template<class t>
vc<t> operator>>(vc<t> a,int k){
return a>>=k;
}
template<class t,class u>
void remval(vc<t>&a,const u&v){
a.erase(remove(all(a),v),a.ed);
}
//消した要素の個数を返してくれる
//UCUP 2-8-F
template<class t,class F>
int remif(vc<t>&a,F f){
auto itr=remove_if(all(a),f);
int res=a.ed-itr;
a.erase(itr,a.ed);
return res;
}
template<class t>
void rempos(vc<t>&a,int i){
assert(inc(0,i,si(a)-1));
a.erase(a.bg+i);
}
template<class VS,class u>
void fila(VS&vs,const u&a){
fill(all(vs),a);
}
template<class t,class u>
int findid(const vc<t>&vs,const u&a){
auto itr=find(all(vs),a);
if(itr==vs.ed)return -1;
else return itr-vs.bg;
}
template<class t>
void rtt(vc<t>&vs,int i){
rotate(vs.bg,vs.bg+i,vs.ed);
}
//Multiuni2023-8 C
//f(lw)=false,...,f(n-1)=false,f(n)=true,...,f(up)=true,
//のときに n を返す
template<class F>
int find_min_true(int lw,int up,F f){
while(up-lw>1){
const int mid=(lw+up)/2;
if(f(mid))up=mid;
else lw=mid;
}
return up;
}
//f(lw)=true,f(up)=false
template<class F>
int find_max_true(int lw,int up,F f){
while(up-lw>1){
const int mid=(lw+up)/2;
if(f(mid))lw=mid;
else up=mid;
}
return lw;
}
template<class t> using pqmin=priority_queue<t,vc<t>,greater<t>>;
template<class t> using pqmax=priority_queue<t>;
using T=tuple<int,int,int>;
//atcoder-library をまあまあコピーして使っている
//N() が単位元
//merge で片方が inactive のときはもう片方をそのまま返す,
//といったときに,lazy の情報までコピーして渡さないようにする
//クエリできる点が[0,s)だったのを[0,n)に変えた (UCUP1-21D)
//ch,max_rightは動くと思う
//ちゃんと test してないから assert とかが壊れたらごめん
//VERIFY:
//https://atcoder.jp/contests/practice2/tasks/practice2_k
template<class N,bool Beats=false>
struct seglazy{
vc<N> x;
int n,L,s;
seglazy(){}
template<class T>
seglazy(const vc<T>& a){
n=a.size();
L=0;
while((1<<L)<n)L++;
s=1<<L;
x.resize(s*2);
rep(i,n)x[s+i]=N(a[i]);
gnr(i,1,s)upd(i);
}
seglazy(int nn){
n=nn;
L=0;
while((1<<L)<n)L++;
s=1<<L;
x.assign(s*2,N());
gnr(i,1,s)upd(i);
}
void upd(int i){
x[i]=N::merge(x[i*2],x[i*2+1]);
}
void push(int i){
x[i].push(x[i*2],x[i*2+1]);
}
//空ノードなしで動く ver が segbeats_norec に書いてある
N composite(int l,int r){
assert(0<=l&&l<=r&&r<=n);
if(l==r)return N();
l+=s;
r+=s;
for (int i = L; i >= 1; i--) {
if (((l >> i) << i) != l) push(l >> i);
if (((r >> i) << i) != r) push((r - 1) >> i);
}
N sml,smr;
while (l < r) {
if (l & 1) sml = N::merge(sml, x[l++]);
if (r & 1) smr = N::merge(x[--r], smr);
l >>= 1;
r >>= 1;
}
return N::merge(sml, smr);
}
//UCUP1-21 D
//JSC2024FinalD
template<class F,class... Args>
void ch_beats(int i,F f,Args&&... args){
int ini=i;
while(1){
if((x[i].*f)(forward<Args>(args)...)){
while(i>ini&&(i&1)){
i>>=1;
upd(i);
}
if(i==ini)break;
i++;
}else{
push(i);
i*=2;
}
}
}
template<class F,class... Args>
void ch(int l, int r, F f,Args&&... args) {
assert(0<=l&&l<=r&&r<=n);
if (l == r) return;
l+=s;
r+=s;
for (int i = L; i >= 1; i--) {
if (((l >> i) << i) != l) push(l >> i);
if (((r >> i) << i) != r) push((r - 1) >> i);
}
static int buf[2][30];
int cnt[2]{};
{
int l2 = l, r2 = r;
while (l < r) {
if (l & 1){
//(x[l++].*f)(forward<Args>(args)...);
buf[0][cnt[0]++]=l++;
}
if (r & 1){
//(x[--r].*f)(forward<Args>(args)...);
buf[1][cnt[1]++]=--r;
}
l >>= 1;
r >>= 1;
}
l = l2;
r = r2;
}
if constexpr(Beats){
rep(i,cnt[0])ch_beats(buf[0][i],f,forward<Args>(args)...);
per(i,cnt[1])ch_beats(buf[1][i],f,forward<Args>(args)...);
}else{
rep(i,cnt[0])(x[buf[0][i]].*f)(forward<Args>(args)...);
per(i,cnt[1])(x[buf[1][i]].*f)(forward<Args>(args)...);
}
for (int i = 1; i <= L; i++) {
if (((l >> i) << i) != l) upd(l >> i);
if (((r >> i) << i) != r) upd((r - 1) >> i);
}
}
template<class F,class... Args>
void chall(F f,Args&&... args){
if constexpr(Beats){
ch_beats(1,f,forward<Args>(args)...);
}else{
(x[1].*f)(forward<Args>(args)...);
}
}
N getall(){return x[1];}
template <class F,class... Args>
pair<int,N> max_right(int l,F f,Args&&... args){
assert(0<=l&&l<=n);
if(l==n)return mp(n,N());
l+=s;
for (int i = L; i >= 1; i--) push(l >> i);
N sm;
assert((sm.*f)(forward<Args>(args)...));
do {
while (l % 2 == 0) l >>= 1;
if (!(N::merge(sm,x[l]).*f)(forward<Args>(args)...)){
while (l < s) {
push(l);
l = (2 * l);
N tmp=N::merge(sm,x[l]);
if ((tmp.*f)(forward<Args>(args)...)) {
sm = tmp;
l++;
}
}
return mp(l - s,sm);
}
sm = N::merge(sm, x[l]);
l++;
} while ((l & -l) != l);
return mp(n,sm);
}
//XXI Opencup Krakow M
template <class F,class... Args>
pair<int,N> min_left(int r,F f,Args&&... args){
assert(0<=r&&r<=n);
if(r==0)return mp(0,N());
r+=s;
for (int i = L; i >= 1; i--) push((r - 1) >> i);
N sm;
do {
r--;
while (r > 1 && (r % 2)) r >>= 1;
if (!(N::merge(x[r],sm).*f)(forward<Args>(args)...)) {
while (r < s) {
push(r);
r = (2 * r + 1);
N tmp=N::merge(x[r],sm);
if ((tmp.*f)(forward<Args>(args)...)) {
sm = tmp;
r--;
}
}
return mp(r + 1 - s,sm);
}
sm = N::merge(x[r], sm);
} while ((r & -r) != r);
return mp(0,sm);
}
template<class F,class...Args>
void point_change(int p,F f,Args&&...args){
assert(0 <= p && p < n);
p += s;
for (int i = L; i >= 1; i--) push(p >> i);
(x[p].*f)(forward<Args>(args)...);
for (int i = 1; i <= L; i++) upd(p >> i);
}
void point_merge(int p,const N&t){
assert(0 <= p && p < n);
p += s;
for (int i = L; i >= 1; i--) push(p >> i);
x[p]=N::merge(x[p],t);
for (int i = 1; i <= L; i++) upd(p >> i);
}
N point_get(int p){
assert(0 <= p && p < n);
p += s;
for (int i = L; i >= 1; i--) push(p >> i);
return x[p];
}
void point_set(int p,N val){
assert(0 <= p && p < n);
p += s;
for (int i = L; i >= 1; i--) push(p >> i);
x[p]=val;
for (int i = 1; i <= L; i++) upd(p >> i);
}
void enumerater(int l,int r,int i,int b,int e,vc<N>&dst){
if(e<=l||r<=b)
return;
if(l+1==r){
dst.pb(x[i]);
return;
}
push(i);
int m=(l+r)/2;
enumerater(l,m,i*2,b,e,dst);
enumerater(m,r,i*2+1,b,e,dst);
}
void enumerate(int b,int e,vc<N>&dst){
assert(0<=b&&b<=e&&e<=n);
return enumerater(0,s,1,b,e,dst);
}
};
struct N{
int val,cnt,wei,sum,lz;
N():val(inf),cnt(0),wei(0),sum(0),lz(0){}
N(int v):val(v),cnt(1),wei(0),sum(0),lz(0){}
void addval(int v){
val+=v;
lz+=v;
}
void addans(int w){
//dmp(val);
assert(val>=1);
if(val==1){
//dmp(cnt);
addwei(w);
}
}
void addwei(int w){
wei+=w;
sum+=cnt*w;
}
void push(N&x,N&y){
x.addval(lz);
y.addval(lz);
lz=0;
if(val==x.val)x.addwei(wei);
if(val==y.val)y.addwei(wei);
wei=0;
}
static N merge(N x,N y){
N res;
res.val=min(x.val,y.val);
if(res.val==x.val){
res.cnt+=x.cnt;
}
if(res.val==y.val){
res.cnt+=y.cnt;
}
res.sum=x.sum+y.sum;
return res;
}
};
void slv(){
INT(n);
VI(a,2*n,-1);
vi pre(2*n,-1);
{
vi buf(n,-1);
rep(i,2*n){
pre[i]=buf[a[i]];
buf[a[i]]=i;
}
}
vi ans(2*n);
rep(k,2){
vi ini(2*n);
rep(i,2*n)if(pre[i]!=-1){
ini[pre[i]]++;
ini[i]--;
}
ini=presum(ini);
for(int i=k^1;i<=2*n;i+=2)ini[i]+=inf;
seglazy<N> seg(ini);
for(int i=2*n;i>0;i--){
if(i%2==(k^1)){
seg.ch(0,i,&N::addans,1);
}
if(pre[i-1]!=-1){
int j=pre[i-1];
ans[i-1]+=seg.composite(j+1,i).sum;
ans[j]-=seg.composite(0,j+1).sum;
seg.ch(j+1,i,&N::addval,-1);
seg.ch(0,j+1,&N::addval,1);
}else{
ans[i-1]+=seg.composite(0,i).sum;
seg.ch(0,i,&N::addval,-1);
}
//dmp(seg.composite(0,4).sum);
//dmp2(k,i,ans[3]);
}
}
print(ans);
}
signed main(signed argc,char*argv[]){
if(argc>1&&strcmp(argv[1],"D")==0)dbg=true;
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(20);
if(dbg){
while(1){
if(current_run_id%run_batch_size==0){
cerr<<"Current Run "<<current_run_id<<endl;
}
slv();
current_run_id++;
}
}else{
//int t;cin>>t;rep(_,t)
slv();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3872kb
input:
2 1 1 2 2
output:
1 2 2 1
result:
ok 4 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 2 1 2 3 1 3
output:
1 2 2 2 2 1
result:
ok 6 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
4 1 2 4 3 4 1 3 2
output:
1 2 1 2 1 3 1 1
result:
ok 8 tokens
Test #4:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
1 1 1
output:
1 1
result:
ok 2 tokens
Test #5:
score: 0
Accepted
time: 2371ms
memory: 124412kb
input:
500000 233733 151347 468353 495903 234861 297169 312993 2734 287872 359375 79017 285205 219439 37290 409190 194953 306816 472906 123794 121028 66509 62235 385879 300188 485875 72413 167304 333428 33910 220100 151575 22575 206653 82054 111518 34032 48702 198940 6262 222529 170641 1735 38943 235003 11...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000000 tokens
Test #6:
score: 0
Accepted
time: 2352ms
memory: 124316kb
input:
499999 20175 421667 477513 164648 153952 133902 58509 432946 498621 54699 294105 304055 93092 259617 486830 464621 6039 242867 382241 360345 10071 252829 103706 252083 473217 323326 33901 422497 383693 356571 238499 427265 431925 199533 488748 223250 479343 214815 342665 7527 397982 388425 441947 22...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 999998 tokens
Test #7:
score: 0
Accepted
time: 2353ms
memory: 124244kb
input:
499997 45410 344491 448636 181028 373083 59862 259850 450733 79631 85900 495425 239044 136232 298896 153214 415427 38484 109664 137285 119717 218023 298593 471654 176162 70510 350483 399376 389216 216264 101701 215546 228021 276411 466038 129279 195937 428850 265629 401774 256885 390764 413922 17303...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 999994 tokens
Test #8:
score: 0
Accepted
time: 2383ms
memory: 124108kb
input:
499997 37608 326519 54760 248123 204348 346642 61147 436793 69778 214333 218891 483667 384161 403360 356390 248198 29856 493073 233598 389736 369609 270007 220631 136593 466701 181463 411612 427328 118151 122803 284544 460648 272586 195734 336665 122951 379375 367270 245020 25504 383525 41863 81696 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 999994 tokens
Test #9:
score: 0
Accepted
time: 2334ms
memory: 124268kb
input:
500000 135935 181205 141645 138625 249427 195506 123419 458633 63023 374714 401464 251761 277589 411743 487913 258512 492432 128739 193919 223871 363101 432296 482273 312836 246225 444114 374199 486518 186449 150064 106819 451666 347007 343676 417429 283175 281930 230703 379421 67177 249744 37489 14...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000000 tokens
Test #10:
score: 0
Accepted
time: 28ms
memory: 6608kb
input:
10363 10142 10142 2131 2738 2131 2738 680 5820 5820 680 5427 5427 5351 5351 5858 2523 2523 5858 441 7894 441 7894 1030 1030 719 719 9367 6333 1473 9367 6333 1473 7794 5563 2057 7794 2057 5563 4537 6187 7424 6187 4537 7424 4036 6607 9275 6607 9275 4036 4467 6358 1636 1636 4467 6358 4832 9601 7151 715...
output:
1 3591 2 3 3591 3590 6 1 1 7178 4 3588 5 3587 12 1 1 7172 7 8 3586 3585 8 3584 9 3583 10 1 11 3583 1 3582 11 12 1 3583 1 3581 12 1 14 1 3581 3580 26 1 2 2 1 7158 14 16 1 1 3580 3578 30 2 1 1 2 7154 16 17 3577 17 3577 3576 17 35 3577 1 1 7150 18 19 3575 3574 19 3573 40 1 1 22 7145 3572 63 1 2 2 1 107...
result:
ok 20726 tokens
Test #11:
score: 0
Accepted
time: 1879ms
memory: 124060kb
input:
499999 395932 97222 230492 15912 230492 255343 255343 97222 15912 395932 5114 483045 466140 64914 153803 327261 213658 466140 153803 64914 2964 487362 283821 280934 487362 483045 5114 283821 50697 327261 280934 50697 2964 213658 375562 126491 470816 375562 126491 470816 450983 67957 450983 67957 183...
output:
2 1 1 4 2 1 1 3 1 140044 2 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 70022 1 1 1 1 1 1 70021 3 1 4 70021 1 70020 4 5 70020 70019 5 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 70019 1 1 1 70018 6 1 1 1 1 1 2 1 7 1 1 1 1 1 1 1 2 1 1 70018 1 1 1 70017 7 1 1 1 1 1 1 1 8 1 1 70017 1 70016 8 1 1 10 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 999998 tokens
Test #12:
score: 0
Accepted
time: 1895ms
memory: 124448kb
input:
499999 142538 184126 163213 171647 240285 423903 240285 163213 184126 142538 171647 423903 218419 444722 307848 309220 417492 309220 218419 444722 253423 253423 246403 246403 417492 307848 1546 256611 460533 179666 460533 33542 256611 33542 1546 182312 182312 179666 494891 494891 297200 342578 57556...
output:
1 1 1 1 1 3 1 1 1 69951 1 69950 2 1 3 1 2 1 69950 3 1 2 2 1 3 69949 3 1 1 9 1 1 2 1 69950 1 1 139896 4 69947 5 7 1 1 2 69949 1 6 69947 69946 6 7 3 1 2 2 1 69949 1 1 3 1 1 2 1 69945 7 1 8 1 69945 1 1 69944 8 69943 9 69942 20 1 1 3 1 1 2 1 1 3 1 2 1 1 1 139882 11 69940 12 14 1 2 2 1 69941 13 69940 13 ...
result:
ok 999998 tokens
Test #13:
score: 0
Accepted
time: 2012ms
memory: 124212kb
input:
499619 50264 179484 186976 224852 311651 162550 298810 487114 157179 227092 71434 374658 258250 58425 151903 171647 152564 397068 65816 380053 379146 374209 49014 170493 320934 135306 124892 357150 167207 455736 160104 486395 95762 449875 118277 418781 218907 89314 337856 30989 310703 53341 419427 3...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 999238 tokens
Test #14:
score: 0
Accepted
time: 2022ms
memory: 124252kb
input:
499606 369879 341625 175849 314032 132747 52381 305513 243923 372249 362042 423054 83571 249322 93226 313191 243365 450797 427667 235086 349991 180477 435583 207087 489095 363133 186894 63517 125104 238559 439605 439605 406039 176030 141309 211195 363491 441590 274803 457716 289474 230268 258356 541...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 479 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 999212 tokens
Test #15:
score: 0
Accepted
time: 1678ms
memory: 124296kb
input:
500000 1 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 52 52...
output:
1 500000 2 499999 3 499998 4 499997 5 499996 6 499995 7 499994 8 499993 9 499992 10 499991 11 499990 12 499989 13 499988 14 499987 15 499986 16 499985 17 499984 18 499983 19 499982 20 499981 21 499980 22 499979 23 499978 24 499977 25 499976 26 499975 27 499974 28 499973 29 499972 30 499971 31 499970...
result:
ok 1000000 tokens
Test #16:
score: 0
Accepted
time: 1801ms
memory: 124300kb
input:
500000 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 1...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000000 tokens
Test #17:
score: 0
Accepted
time: 1852ms
memory: 124396kb
input:
500000 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 1...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 1000000 tokens
Test #18:
score: 0
Accepted
time: 1797ms
memory: 124216kb
input:
500000 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 1...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000000 tokens
Test #19:
score: 0
Accepted
time: 1758ms
memory: 124312kb
input:
500000 1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12 11 12 13 14 13 14 15 16 15 16 17 18 17 18 19 20 19 20 21 22 21 22 23 24 23 24 25 26 25 26 27 28 27 28 29 30 29 30 31 32 31 32 33 34 33 34 35 36 35 36 37 38 37 38 39 40 39 40 41 42 41 42 43 44 43 44 45 46 45 46 47 48 47 48 49 50 49 50 51 52 51 52...
output:
1 2 250001 250000 2 3 250000 249999 3 4 249999 249998 4 5 249998 249997 5 6 249997 249996 6 7 249996 249995 7 8 249995 249994 8 9 249994 249993 9 10 249993 249992 10 11 249992 249991 11 12 249991 249990 12 13 249990 249989 13 14 249989 249988 14 15 249988 249987 15 16 249987 249986 16 17 249986 2499...
result:
ok 1000000 tokens
Test #20:
score: 0
Accepted
time: 1937ms
memory: 124316kb
input:
500000 11 4 8 2 14 15 26 26 23 30 23 25 103 115 112 116 109 122 115 125 117 122 113 112 108 34473 34474 34475 34472 34474 34472 34471 61922 61915 61922 61918 61917 164274 164267 164265 164272 164265 164271 167825 167812 192706 192704 192707 192705 192705 192702 192704 307675 307671 307670 307679 307...
output:
1 1 1 3 1 3 1 2 2 3 2 2 2 1 1 1 1 1 2 1 1 1 1 1 2 1 1 2 1 2 1 4 1 2 2 1 5 1 1 1 2 1 2 1 2 2 1 3 1 1 2 5 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 3 1 2 1 1 1 1 2 1 1 2 2 1 1 2 2 1 3 3 1 2 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000000 tokens
Test #21:
score: 0
Accepted
time: 1942ms
memory: 124272kb
input:
500000 2 7 9 8 44 40 46 31 33 34 61 58 55 109 105 104 112 106 113 105 108 14336 14339 14335 14340 29421 141122 141129 141129 141122 141121 141118 141124 141121 141120 141125 141123 141130 141119 141126 141128 141127 141125 141126 141128 141127 186887 186877 186881 186884 186879 186883 186876 186877 ...
output:
6 1 4 2 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 1 1 2 3 2 1 1 4 2 1 3 2 1 1 1 1 1 1 1 1 4 1 1 2 1 1 3 1 1 1 1 3 1 1 1 1 1 2 1 1 1 1 1 3 1 1 2 1 2 1 2 1 1 3 1 1 4 1 1 2 2 1 3 2 1 1 2 1 1 1 2 1 2 2 1 1 1 1 6 1 1 2 4 1 1 2 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 2 1 2 1 1 1 1 1 1 ...
result:
ok 1000000 tokens
Test #22:
score: 0
Accepted
time: 2003ms
memory: 124088kb
input:
500000 134 57 24 426 60 186 174 300 291 549 324 9 455 202 517 83 261 87 259 86 151 444 79 360 142 280 538 213 335 123 200 184 67 313 287 177 30 95 483 84 323 436 5 1 330 199 516 338 540 115 206 205 2 131 448 397 216 395 101 215 298 339 296 15 265 385 315 330 46 370 329 175 607 112 230 486 323 30 68 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 ...
result:
ok 1000000 tokens
Test #23:
score: 0
Accepted
time: 1999ms
memory: 124240kb
input:
500000 46 94 74 141 1 10 132 16 107 116 8 2 78 5 123 146 85 55 26 105 119 147 144 104 24 39 25 9 90 33 58 23 144 149 82 27 136 115 329 194 319 300 310 205 330 212 305 199 808 545 408 421 847 738 485 447 766 448 554 823 637 858 806 829 575 706 726 446 644 804 550 460 1291 1477 1443 1413 1671 1216 140...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000000 tokens
Extra Test:
score: 0
Extra Test Passed