QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#103712 | #6404. Shuttle Tour | tute7627 | AC ✓ | 2093ms | 155072kb | C++17 | 18.0kb | 2023-05-07 12:25:17 | 2023-05-07 12:25:18 |
Judging History
answer
//#define _GLIBCXX_DEBUG
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug_print.hpp>
#define OUT(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define OUT(...) (static_cast<void>(0))
#endif
#define endl '\n'
#define lfs cout<<fixed<<setprecision(15)
#define ALL(a) (a).begin(),(a).end()
#define ALLR(a) (a).rbegin(),(a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using QP = priority_queue<T,vector<T>,greater<T>>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T1,typename T2,typename T3>void anss(T1 x,T2 y,T3 z){ans(x!=y,x,z);};
template<typename T>void debug(const T &v,ll h,ll w,string sv=" "){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout<<sv<<v[i][j];cout<<endl;}};
template<typename T>void debug(const T &v,ll n,string sv=" "){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout<<sv<<v[i];cout<<endl;};
template<typename T>void debug(const vector<T>&v){debug(v,v.size());}
template<typename T>void debug(const vector<vector<T>>&v){for(auto &vv:v)debug(vv,vv.size());}
template<typename T>void debug(stack<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(queue<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(deque<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop_front();}cout<<endl;}
template<typename T>void debug(PQ<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(QP<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(const set<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T>void debug(const multiset<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T,size_t size>void debug(const array<T, size> &a){for(auto z:a)cout<<z<<" ";cout<<endl;}
template<typename T,typename V>void debug(const map<T,V>&v){for(auto z:v)cout<<"["<<z.first<<"]="<<z.second<<",";cout<<endl;}
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << "(" << p.first << "," << p.second << ")";}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){os<<"[";for(auto &z:v)os << z << ",";os<<"]"; return os;}
template<typename T>void rearrange(vector<int>&ord, vector<T>&v){
auto tmp = v;
for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<int>&ord,Head&& head, Tail&&... tail){
rearrange(ord, head);
rearrange(ord, tail...);
}
template<typename T> vector<int> ascend(const vector<T>&v){
vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],i)<make_pair(v[j],j);});
return ord;
}
template<typename T> vector<int> descend(const vector<T>&v){
vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],-i)>make_pair(v[j],-j);});
return ord;
}
template<typename T> vector<T> inv_perm(const vector<T>&ord){
vector<T>inv(ord.size());
for(int i=0;i<ord.size();i++)inv[ord[i]] = i;
return inv;
}
ll FLOOR(ll n,ll div){assert(div>0);return n>=0?n/div:(n-div+1)/div;}
ll CEIL(ll n,ll div){assert(div>0);return n>=0?(n+div-1)/div:n/div;}
ll digitsum(ll n){ll ret=0;while(n){ret+=n%10;n/=10;}return ret;}
ll modulo(ll n,ll d){return (n%d+d)%d;};
template<typename T>T min(const vector<T>&v){return *min_element(v.begin(),v.end());}
template<typename T>T max(const vector<T>&v){return *max_element(v.begin(),v.end());}
template<typename T>T acc(const vector<T>&v){return accumulate(v.begin(),v.end(),T(0));};
template<typename T>T reverse(const T &v){return T(v.rbegin(),v.rend());};
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};
template<typename T>T poll(queue<T> &q){auto ret=q.front();q.pop();return ret;};
template<typename T>T poll(priority_queue<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(QP<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(stack<T> &s){auto ret=s.top();s.pop();return ret;};
ll MULT(ll x,ll y){if(LLONG_MAX/x<=y)return LLONG_MAX;return x*y;}
ll POW2(ll x, ll k){ll ret=1,mul=x;while(k){if(mul==LLONG_MAX)return LLONG_MAX;if(k&1)ret=MULT(ret,mul);mul=MULT(mul,mul);k>>=1;}return ret;}
ll POW(ll x, ll k){ll ret=1;for(int i=0;i<k;i++){if(LLONG_MAX/x<=ret)return LLONG_MAX;ret*=x;}return ret;}
namespace converter{
int dict[500];
const string lower="abcdefghijklmnopqrstuvwxyz";
const string upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string digit="0123456789";
const string digit1="123456789";
void regi_str(const string &t){
for(int i=0;i<t.size();i++){
dict[t[i]]=i;
}
}
void regi_int(const string &t){
for(int i=0;i<t.size();i++){
dict[i]=t[i];
}
}
vector<int>to_int(const string &s,const string &t){
regi_str(t);
vector<int>ret(s.size());
for(int i=0;i<s.size();i++){
ret[i]=dict[s[i]];
}
return ret;
}
vector<int>to_int(const string &s){
auto t=s;
sort(t.begin(),t.end());
t.erase(unique(t.begin(),t.end()),t.end());
return to_int(s,t);
}
vector<vector<int>>to_int(const vector<string>&s,const string &t){
regi_str(t);
vector<vector<int>>ret(s.size(),vector<int>(s[0].size()));
for(int i=0;i<s.size();i++){
for(int j=0;j<s[0].size();j++){
ret[i][j]=dict[s[i][j]];
}
}
return ret;
}
vector<vector<int>>to_int(const vector<string>&s){
string t;
for(int i=0;i<s.size();i++){
t+=s[i];
}
sort(t.begin(),t.end());t.erase(unique(t.begin(),t.end()),t.end());
return to_int(s,t);
}
string to_str(const vector<int>&s,const string &t){
regi_int(t);
string ret;
for(auto z:s)ret+=dict[z];
return ret;
}
vector<string> to_str(const vector<vector<int>>&s,const string &t){
regi_int(t);
vector<string>ret(s.size());
for(int i=0;i<s.size();i++){
for(auto z:s[i])ret[i]+=dict[z];
}
return ret;
}
}
template< typename T = int >
struct edge {
int to;
T cost;
int id;
edge():to(-1),id(-1){};
edge(int to, T cost = 1, int id = -1):to(to), cost(cost), id(id){}
operator int() const { return to; }
};
template<typename T>
using Graph = vector<vector<edge<T>>>;
template<typename T>
Graph<T>revgraph(const Graph<T> &g){
Graph<T>ret(g.size());
for(int i=0;i<g.size();i++){
for(auto e:g[i]){
int to = e.to;
e.to = i;
ret[to].push_back(e);
}
}
return ret;
}
template<typename T>
Graph<T> readGraph(int n,int m,int indexed=1,bool directed=false,bool weighted=false){
Graph<T> ret(n);
for(int es = 0; es < m; es++){
int u,v;
T w=1;
cin>>u>>v;u-=indexed,v-=indexed;
if(weighted)cin>>w;
ret[u].emplace_back(v,w,es);
if(!directed)ret[v].emplace_back(u,w,es);
}
return ret;
}
template<typename T>
Graph<T> readParent(int n,int indexed=1,bool directed=true){
Graph<T>ret(n);
for(int i=1;i<n;i++){
int p;cin>>p;
p-=indexed;
ret[p].emplace_back(i);
if(!directed)ret[i].emplace_back(p);
}
return ret;
}
template< typename Monoid ,typename F>
struct SegmentTree {
int sz, n;
vector< Monoid > seg;
const F f;
const Monoid M1;
SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1), n(n){
sz = 1;
while(sz < n) sz <<= 1;
seg.assign(2 * sz, M1);
}
void set(int k, const Monoid &x) {
seg[k + sz] = x;
}
void build() {
for(int k = sz - 1; k > 0; k--) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
void update(int k, const Monoid &x) {
k += sz;
seg[k] = x;
while(k >>= 1) {
seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
}
}
Monoid query(int a, int b) {
if(a>=b)return M1;
Monoid L = M1, R = M1;
for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
if(a & 1) L = f(L, seg[a++]);
if(b & 1) R = f(seg[--b], R);
}
return f(L, R);
}
Monoid operator[](const int &k) const {
return seg[k + sz];
}
template< typename C >
int find_subtree(int a, const C &check, Monoid &M, bool type) {
while(a < sz) {
Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
if(check(nxt)) a = 2 * a + type;
else M = nxt, a = 2 * a + 1 - type;
}
return a - sz;
}
//[a,x]が条件を満たす最初のx,満たさなければn
template< typename C >
int find_first(int a, const C &check) {
Monoid L = M1;
if(a <= 0) {
if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
return n;
}
int b = sz;
for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
if(a & 1) {
Monoid nxt = f(L, seg[a]);
if(check(nxt)) return find_subtree(a, check, L, false);
L = nxt;
++a;
}
}
return n;
}
//[x,b)が条件を満たす最後のx,満たさなければ-1
template< typename C >
int find_last(int b, const C &check) {
Monoid R = M1;
if(b >= sz) {
if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
return -1;
}
int a = sz;
for(b += sz; a < b; a >>= 1, b >>= 1) {
if(b & 1) {
Monoid nxt = f(seg[--b], R);
if(check(nxt)) return find_subtree(b, check, R, true);
R = nxt;
}
}
return -1;
}
void print(){
for(ll i=0;i<n;i++)if((*this)[i]==M1)cout<<"x ";else cout<<(*this)[i]<<" ";
cout<<endl;
}
};
template<typename T>
struct HLD{
using D=long long;
int n;
vector<int>sz;//部分木サイズ
vector<D>dep;
vector<int>par;
vector<int>head;
Graph<T> &g;//隣接リスト
vector<edge<T>>edges;//データ構造に乗せるedge列
vector<int>in,out;//[in,out)で部分木、[ina,inb]でa~bのパス(aが上)
vector<int>comp;//連結成分の根
//inは頂点のindexを表す。また、edge列の下側の頂点である
HLD(Graph<T> &g,int r=-1):g(g),n(g.size()){
hld_build(r);
}
void hld_build(int root = -1){
in.assign(n,-1);out.assign(n,-1);dep.assign(n,0);
par.assign(n,-1);head.assign(n,-1);sz.assign(n,-1);comp.assign(n,-1);
edges.assign(n,edge<T>());
if(root == -1){//根がどこでも良い場合(森でも可)
for(int i=0;i<n;i++){
if(sz[i] == -1){
head[i] = i;
dfs_sz(i, 0, i);
dfs_hld(i);
}
}
}
else{
head[root] = root;
dfs_sz(root, 0, root);
dfs_hld(root);
}
}
void dfs_sz(int k, D d,int r){
sz[k] = 1;
comp[k] = r;
dep[k] = d;
for(auto &e: g[k]){
if(e.to == par[k])continue;
par[e.to] = k;
dfs_sz(e.to, d+e.cost, r);
sz[k] += sz[e.to];
if(g[k][0].to==par[k]||sz[e.to] > sz[g[k][0].to])swap(e, g[k][0]);
}
}
int time = 0;
void dfs_hld(int k){
in[k] = time++;
for(auto e:g[k]){
if(e.to == par[k])continue;
head[e.to] = (e.to == g[k][0].to ? head[k]: e.to);
edges[time] = e;
dfs_hld(e.to);
}
out[k] = time;
}
int lca(int p,int q){
while(1){
if(in[p] < in[q])swap(p,q);
if(head[p] == head[q])return q;
p = par[head[p]];
}
}
vector<pair<int,int>>query_path(int p,int q,bool isEdge){
int r=lca(p,q);
vector<pair<int,int>>ret;
for(int i=0;i<2;i++){
if(i == 1)swap(p,q);
while(1){
if(isEdge&&p==r)break;
if(head[p]==head[r]){
ret.emplace_back(in[r]+(isEdge?1:i),in[p]+1);
break;
}
ret.emplace_back(in[head[p]],in[p]+1);
p = par[head[p]];
}
}
return ret;
}
vector<vector<pair<int,int>>>query_order_path(int p,int q,bool isEdge){
//非可換クエリ用、配列0を順番を反転したデータ構造に、配列1を通常のデータ構造に
vector<vector<pair<int,int>>>ret(2);
int r=lca(p,q);
for(int i=0;i<2;i++){
if(i == 1)swap(p,q);
while(1){
if(isEdge&&p==r)break;
if(head[p]==head[r]){
if(i==0) ret[i].emplace_back(n-(in[p]+1),n-(in[r]+(isEdge?1:i)));
else ret[i].emplace_back(in[r]+(isEdge?1:i),in[p]+1);
break;
}
if(i==0) ret[i].emplace_back(n-(in[p]+1),n-(in[head[p]]));
else ret[i].emplace_back(in[head[p]],in[p]+1);
p = par[head[p]];
}
}
reverse(ret[1].begin(), ret[1].end());
return ret;
}
pair<int,int>query_subtree(int p,bool isEdge){
return make_pair(in[p]+isEdge,out[p]);
}
//uのv方向の子 子孫関係は前もって確認すること(in,outを見る)
int child(int u,int v)const{
while(1){
if(head[u]==head[v]){
v=g[u][0].to;
break;
}
v=head[v];
if(par[v]==u)break;
v=par[v];
}
return v;
}
//uをv方向に一つ進めた頂点
int move(int u,int v)const{
assert(u!=v);
if(in[u]<in[v]&&in[v]<out[u])return child(u,v);
else return par[u];
}
D dist(int u,int v){
return dep[u]+dep[v]-2*dep[lca(u,v)];
}
vector<int>rev_in;
int climb(int u,int k){
if(rev_in.empty()){
rev_in.resize(n);
for(int i=0;i<n;i++)rev_in[in[i]]=i;
}
int nd=max<int>(dep[u]-k, 0);
while(dep[u]>nd){
if(dep[head[u]]>nd){
u=par[head[u]];
}
else{
u=rev_in[in[head[u]]+nd-dep[head[u]]];
}
}
return u;
}
int jump(int from,int to, int k){
int r = lca(from, to);
int d1 = dep[from] - dep[r];
int d2 = dep[to] - dep[r];
if(d1 + d2 < k)return -1;
else if(k <= d1)return climb(from, k);
else return climb(to, d1 + d2 - k);
}
template<typename I>
Graph<T>lca_tree(vector<I>&v){
auto compare=[&](int x,int y){return in[x]<in[y];};
sort(v.begin(),v.end(),compare);
int sz1=v.size();
for(int i=0;i<sz1-1;i++)v.push_back(lca(v[i],v[i+1]));
sort(v.begin(),v.end(),compare);
v.erase(unique(v.begin(),v.end()),v.end());
int sz2=v.size();
Graph<T>ret(sz2);
stack<int>st;
for(int i=0;i<sz2;i++){
while(!st.empty()&&out[v[st.top()]]<=in[v[i]])st.pop();
if(!st.empty()){
ret[st.top()].emplace_back(i,dep[v[i]]-dep[v[st.top()]]);
ret[i].emplace_back(st.top(),dep[v[i]]-dep[v[st.top()]]);
}
st.push(i);
}
return ret;
}
};
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll res=0,buf=0;
bool judge = true;
int n,q;cin>>n>>q;
string _s;cin>>_s;
auto s=converter::to_int(_s,"01");
auto g=readGraph<ll>(n,n-1,1,false,true);
HLD hld(g);
const int sz=52;
using A=array<int,sz>;
A ident;
rep(i,0,sz)ident[i]=n;
auto in=hld.in;
in.PB(n+1);
auto check=[&](int anc,int ch){
return in[anc]<=in[ch]&&in[ch]<hld.out[anc];
};
auto fmi=[&](int x,int y){
if(in[x]<in[y])return x;
else return y;
};
SegmentTree segin(n,fmi,n);
auto f=[&](A x,A y){
A z=ident;
int xi=0,yi=0;
int idx=0;
while(x[xi]!=n||y[yi]!=n){
if(in[x[xi]]<in[y[yi]]){
if(idx>0&&check(z[idx-1],x[xi])){
idx--;
}
z[idx++]=x[xi++];
}
else{
if(idx>0&&check(z[idx-1],y[yi])){
idx--;
}
z[idx++]=y[yi++];
}
}
return z;
};
SegmentTree seg(n,f,ident);
rep(i,0,n){
if(s[i]){
auto tmp=ident;
tmp[0]=i;
seg.set(i,tmp);
segin.set(i,i);
}
}
segin.build();
seg.build();
while(q--){
int type;cin>>type;
if(type==1){
int x;cin>>x;x--;
s[x]^=1;
if(s[x]==0){
seg.update(x,ident);
segin.update(x,n);
}
else{
auto tmp=ident;
tmp[0]=x;
seg.update(x,tmp);
segin.update(x,x);
}
}
else{
int l,r;cin>>l>>r;l--;
auto vv=seg.query(l,r);
vector<int>v;
auto ff=segin.query(l,r);
if(ff!=n)v.PB(ff);
for(auto z:vv)if(z!=n)v.PB(z);
if(v.empty()){
cout<<-1<<endl;
continue;
}
ll sum=0;
rep(i,0,v.size()){
sum+=hld.dist(v[i],v[(i+1)%v.size()]);
}
cout<<sum<<endl;
}
//rep(i,1,seg.seg.size())OUT(i,seg.seg[i]);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3428kb
input:
5 6 10110 1 2 1 1 3 10 2 4 100 3 5 1000 2 1 5 1 3 2 1 5 2 2 4 2 5 5 2 1 1
output:
222 202 0 -1 0
result:
ok 5 number(s): "222 202 0 -1 0"
Test #2:
score: 0
Accepted
time: 140ms
memory: 3528kb
input:
50 200000 00100100100001101010110100000111100011101110011010 14 47 940241413 11 43 331483591 37 38 496247070 47 46 832459694 7 15 16479291 1 30 402388666 30 8 513064064 46 50 739311480 5 4 761894947 32 41 631669659 17 24 715786564 35 20 763151642 32 33 492466005 39 11 186023146 9 7 805081251 3 42 25...
output:
17149847378 -1 26540740138 29613692754 21307948558 27003443184 11893407374 18332625722 20412196350 20281573062 29727468956 9593307160 9380710234 23682775470 16688997988 2856655228 14982588156 0 -1 9140136614 26193602866 22558599316 24807163344 19126284190 8533875940 7695830712 18079494744 0 27004673...
result:
ok 100000 numbers
Test #3:
score: 0
Accepted
time: 147ms
memory: 3440kb
input:
50 200000 10010001110011101101101011010011100101101010111001 1 25 560163135 2 7 696374536 33 39 14485266 39 22 456690113 4 5 267811886 18 6 657680382 3 43 865617406 25 14 885515220 41 34 919525052 42 50 410634144 8 3 487403277 3 30 701549676 2 43 54223104 7 34 691078766 14 23 323352590 26 48 4936558...
output:
17177676326 31373486130 15290175638 8192974494 22734716092 27802380120 6315957348 0 15780401446 15929384564 26423899248 9639532596 21199366790 26413065782 -1 29063665908 29925313598 28651879288 17144176262 16526083688 28206620550 26873163342 14840246174 32414950818 29985336496 0 11937422088 11131990...
result:
ok 100000 numbers
Test #4:
score: 0
Accepted
time: 134ms
memory: 3476kb
input:
50 200000 01011001001010000100001101100111011001101011101000 34 29 654100339 33 5 947063765 45 25 962067151 11 13 509130797 26 47 988757358 49 22 75267557 7 11 431530851 46 1 531969122 22 43 449891945 34 6 526679193 50 17 499004364 22 23 226725950 26 48 203414490 11 44 900725507 10 29 451714017 35 2...
output:
24080362406 0 0 21418182584 28358635244 28257750030 24520294678 21418182584 0 15335211126 28621468542 18664505530 19335499776 32374868794 23618866752 26801803500 24116134918 27676993638 30222353942 25612316674 20504702130 28400398734 29472795250 24400110084 20586186786 25612316674 0 30067400886 1297...
result:
ok 100000 numbers
Test #5:
score: 0
Accepted
time: 2ms
memory: 3488kb
input:
2 10 01 1 2 340134039 2 1 2 1 1 2 1 2 1 2 2 1 1 1 2 2 2 2 1 2 2 2 2 1 1
output:
0 680268078 0 0 -1
result:
ok 5 number(s): "0 680268078 0 0 -1"
Test #6:
score: 0
Accepted
time: 233ms
memory: 154956kb
input:
200000 100 1100001001001101010000111111011011101010001011011011011010101111010001111010101100101001010000110100100011111010011100101010010001011010111100101110010000101010000100111100000011001100111101110011000011010011011011100101100111101010111101110111001111111010001010010000110110100000111000111...
output:
187263442365796 187267199881816 187176203274470 187269896250018 187239740690858 186974761323092 187257776119514 187269896250018 187035239640930 186911636122472 187263030332128 187121605387264 187264313877130 187263442365796 187269896250018 187249588971104 187263442365796 187263442365796 187264313877...
result:
ok 50 numbers
Test #7:
score: 0
Accepted
time: 260ms
memory: 155072kb
input:
200000 100 1000100001000101011000010111101000110001110111010000000010100100001110001110011001001011000010001000101111000111000100111101111111011111101101011110010101110000011011000101010000101110000100101000101110011111110000010011010010001001010001101000001111001001011111110100100011011100010100101...
output:
187406582272754 187713357625510 187713357625510 187710409039730 187708440524170 187705546874918 187675370061160 187696435101958 187704004975728 187708440524170 187708440524170 187490194913408 186797006090958 187708440524170 187708440524170 187694259450196 187691068337432 187699562335668 187708440524...
result:
ok 50 numbers
Test #8:
score: 0
Accepted
time: 230ms
memory: 143816kb
input:
200000 100 1101110101111010101100101110111101001010101100011111011010101101001011000101011011110110110001000000110000100110101010001011100110100101010110001111000100011010101011100011111010111001011110110001001010000001010100000000100010010000110100101010000111010100100111001011101001000011010101011...
output:
187071935465024 186902015424650 186944515923806 187083386398370 187083386398370 186176053533638 187210565613960 186840136921858 187059112646348 186963648681914 187157614978100 187171857507720 186687953621656 187037985042418 184267618052908 185811051686090 186716949587794 186666528269428 186754258305...
result:
ok 50 numbers
Test #9:
score: 0
Accepted
time: 2043ms
memory: 144588kb
input:
200000 200000 1010011001010010101000001000111111110110111100000011000110010101000001101110111000100011010101100011001011101100010100000010100000100110100001000111010000011001010111001001000000111001100110010100101010111000000000011110101110010101110110110101100001011001101010101001000010000010000000...
output:
185874943612396 186901189463748 185325592077116 187007806200644 185723936146376 186683200699722 186830061692652 186256265895174 186860903405924 186810412385682 186744028102060 186994420108608 186831837842360 180459525430870 186966649455016 186952309712742 185810351127924 186849618327982 186494273101...
result:
ok 100000 numbers
Test #10:
score: 0
Accepted
time: 2024ms
memory: 143712kb
input:
200000 200000 1101100101010001011001101010110111010000001100111000100010001111101101110111001101000001101011010000001110101101001010011000001011000101010111001101100100101001100111010001101010011100101100010110000011110101101011000011101101010111101000000111100100011101000110011100011000010010001011...
output:
187559700459682 187535810670694 187366757549978 187509694959444 186405180245408 187572993046976 186802217032708 186278525122374 187171989295434 187404069323808 187366390326582 184670301024044 186230793287498 187530780070456 187597311483370 187406310330638 187384636670170 187047338416520 187544270920...
result:
ok 100000 numbers
Test #11:
score: 0
Accepted
time: 2093ms
memory: 143712kb
input:
200000 200000 0011111000111101101011111111000010101011010000100000110110010110010000011010101011101001100001001001000001100110010100101101001111000111010011110100000100000001111111000001000101000011110001101101111000101001100010010011001101100111110000110001100001100011110011001100100010000010001101...
output:
187057082821034 187050489592834 185798962075874 186490497612254 185547643085476 185839649755426 186731725449660 186845143722558 186446910671932 186830913714546 186903848544526 186827856700414 187012840145598 187030896936824 186738571374322 186338959389628 186977751482606 187075649881228 186978915850...
result:
ok 100000 numbers
Test #12:
score: 0
Accepted
time: 2ms
memory: 3408kb
input:
1 3 0 2 1 1 1 1 2 1 1
output:
-1 0
result:
ok 2 number(s): "-1 0"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3448kb
input:
7 2 0001100 1 2 1 2 3 10 3 4 100 4 5 1000 3 6 10000 6 7 100000 2 1 7 2 2 6
output:
2000 2000
result:
ok 2 number(s): "2000 2000"