QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#101391 | #6190. Graph Problem | maroonrk | AC ✓ | 2826ms | 9508kb | C++20 | 16.5kb | 2023-04-29 13:18:42 | 2023-04-29 13:18:43 |
Judging History
answer
#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif
#include <bits/stdc++.h>
using namespace std;
//fast IO by yosupo
//sc.read(string) だと append される
struct Scanner {
FILE* fp = nullptr;
char line[(1 << 15) + 1];
size_t st = 0, ed = 0;
void reread() {
memmove(line, line + st, ed - st);
ed -= st;
st = 0;
ed += fread(line + ed, 1, (1 << 15) - ed, fp);
line[ed] = '\0';
}
bool succ() {
while (true) {
if (st == ed) {
reread();
if (st == ed) return false;
}
while (st != ed && isspace(line[st])) st++;
if (st != ed) break;
}
if (ed - st <= 50) reread();
return true;
}
template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
bool read_single(T& ref) {
if (!succ()) return false;
ref.clear();
while (true) {
size_t sz = 0;
while (st + sz < ed && !isspace(line[st + sz])) sz++;
ref.append(line + st, sz);
st += sz;
if (!sz || st != ed) break;
reread();
}
return true;
}
template <class T, enable_if_t<is_integral<T>::value, int> = 0>
bool read_single(T& ref) {
if (!succ()) return false;
bool neg = false;
if (line[st] == '-') {
neg = true;
st++;
}
ref = T(0);
while (isdigit(line[st])) {
ref = 10 * ref + (line[st++] - '0');
}
if (neg) ref = -ref;
return true;
}
template <class T> bool read_single(vector<T>& ref) {
for (auto& d : ref) {
if (!read_single(d)) return false;
}
return true;
}
void read() {}
template <class H, class... T> void read(H& h, T&... t) {
bool f = read_single(h);
assert(f);
read(t...);
}
Scanner(FILE* _fp) : fp(_fp) {}
};
struct Printer {
public:
template <bool F = false> void write() {}
template <bool F = false, class H, class... T>
void write(const H& h, const T&... t) {
if (F) write_single(' ');
write_single(h);
write<true>(t...);
}
template <class... T> void writeln(const T&... t) {
write(t...);
write_single('\n');
}
Printer(FILE* _fp) : fp(_fp) {}
~Printer() { flush(); }
private:
static constexpr size_t SIZE = 1 << 15;
FILE* fp;
char line[SIZE], small[50];
size_t pos = 0;
void flush() {
fwrite(line, 1, pos, fp);
pos = 0;
}
void write_single(const char& val) {
if (pos == SIZE) flush();
line[pos++] = val;
}
template <class T, enable_if_t<is_integral<T>::value, int> = 0>
void write_single(T val) {
if (pos > (1 << 15) - 50) flush();
if (val == 0) {
write_single('0');
return;
}
if (val < 0) {
write_single('-');
val = -val; // todo min
}
size_t len = 0;
while (val) {
small[len++] = char('0' + (val % 10));
val /= 10;
}
for (size_t i = 0; i < len; i++) {
line[pos + i] = small[len - 1 - i];
}
pos += len;
}
void write_single(const string& s) {
for (char c : s) write_single(c);
}
void write_single(const char* s) {
size_t len = strlen(s);
for (size_t i = 0; i < len; i++) write_single(s[i]);
}
template <class T> void write_single(const vector<T>& val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) write_single(' ');
write_single(val[i]);
}
}
void write_single(long double d){
{
long long v=d;
write_single(v);
d-=v;
}
write_single('.');
for(int _=0;_<8;_++){
d*=10;
long long v=d;
write_single(v);
d-=v;
}
}
};
Scanner sc(stdin);
Printer pr(stdout);
using ll=long long;
//#define int ll
#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>;
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));
}
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<<"}";
}
ll read(){
ll i;
cin>>i;
return i;
}
vi readvi(int n,int off=0){
vi v(n);
rep(i,n)v[i]=read()+off;
return v;
}
pi readpi(int off=0){
int a,b;cin>>a>>b;
return pi(a+off,b+off);
}
template<class t>
void print_single(t x,int suc=1){
cout<<x;
if(suc==1)
cout<<"\n";
if(suc==2)
cout<<" ";
}
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?suc:2);
}
template<class T>
void print_offset(const vector<T>&v,ll off,int suc=1){
rep(i,v.size())
print_single(v[i]+off,i==int(v.size())-1?suc:2);
}
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?suc:2);
}
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...);
}
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);
}
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 t> void mkuni(vc<t>&v){
sort(all(v));
v.erase(unique(all(v)),v.ed);
}
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);
}
template<class t>
void myshuffle(vc<t>&a){
rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}
template<class t>
int lwb(const vc<t>&v,const t&a){
return lower_bound(all(v),a)-v.bg;
}
template<class t>
bool bis(const vc<t>&v,const t&a){
return binary_search(all(v),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> readTree(int n){
return readGraph(n,n-1);
}
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>
t MAX(const vc<t>&a){
return *max_element(all(a));
}
template<class t>
t MIN(const vc<t>&a){
return *min_element(all(a));
}
template<class t,class u>
pair<t,u> operator+(const pair<t,u>&a,const pair<t,u>&b){
return mp(a.a+b.a,a.b+b.b);
}
vi vid(int n){
vi res(n);iota(all(res),0);
return res;
}
template<class S>
S getrev(S s){
reverse(all(s));
return s;
}
pi operator+(pi a,pi b){return pi(a.a+b.a,a.b+b.b);}
//Montgomery
struct modinfo{
using u128=__uint128_t;
ull n,n2,r,t,e;
modinfo(ull nn){
n=nn;
assert(n<(1ull<<62));
assert(n%2==1);
n2=n*2;
r=n&3;
rep(_,5)r*=2-n*r;
r=-r;
assert(r*n==-1ull);
t=-ull(n)%n;
e=-u128(n)%n;
}
ull add(ull x,ull y)const{x+=y;return x<n2?x:x-n2;}
ull re(u128 x)const{return (x+u128(ull(x)*r)*n)>>64;}
ull mult(ull x,ull y)const{return re(u128(x)*y);}
ull en(ull x)const{return mult(x,e);}
ull de(ull x)const{x=re(x);return x<n?x:x-n;}
};
template<modinfo const&ref>
struct modular{
static constexpr ull const &mod=ref.n;
static constexpr ull const &mod2=ref.n2;
ull v;
modular(ll vv=0){v=ref.en(vv%mod+mod);}
modular operator-()const{return modular()-*this;}
modular&operator+=(const modular&rhs){v=ref.add(v,rhs.v);return *this;}
modular&operator-=(const modular&rhs){v=ref.add(v,mod2-rhs.v);return *this;}
modular&operator*=(const modular&rhs){v=ref.mult(v,rhs.v);return *this;}
modular&operator/=(const modular&rhs){return *this*=rhs.inv();}
modular operator+(const modular&rhs)const{return modular(*this)+=rhs;}
modular operator-(const modular&rhs)const{return modular(*this)-=rhs;}
modular operator*(const modular&rhs)const{return modular(*this)*=rhs;}
modular operator/(const modular&rhs)const{return modular(*this)/=rhs;}
modular pow(ll n)const{
modular res(1),x(*this);
while(n){
if(n&1)res*=x;
x*=x;
n>>=1;
}
return res;
}
modular inv()const{return pow(mod-2);}
friend modular operator+(ll x,const modular&y){
return modular(x)+y;
}
friend modular operator-(ll x,const modular&y){
return modular(x)-y;
}
friend modular operator*(ll x,const modular&y){
return modular(x)*y;
}
friend modular operator/(ll x,const modular&y){
return modular(x)/y;
}
ull val()const{return ref.de(v);}
friend ostream& operator<<(ostream&os,const modular&m){
return os<<m.val();
}
friend istream& operator>>(istream&is,modular&m){
ll x;is>>x;
m=modular(x);
return is;
}
bool operator<(const modular&r)const{return v<r.v;}
bool operator==(const modular&r)const{return v==r.v;}
bool operator!=(const modular&r)const{return v!=r.v;}
explicit operator bool()const{
return val();
}
};
template<class mint>
ll m2l(mint a){
ull v=a.val();
return v<mint::mod/2?v:ll(v)-ll(mint::mod);
}
const modinfo base(4611686018427387847ll);
//modinfo base(1);
using mint=modular<base>;
//inplace
//左c列をsweepしする
//aの先頭rank行に要素が入っている感じ
//Yuhao Du Contest 11 (Ucup1-10 G)
int sweep(vvc<mint>&a,int c=-1){
if(a.empty())return -1;
if(c==-1)c=a[0].size();
int h=a.size(),w=a[0].size(),r=0;
rep(i,c){
if(r==h)break;
rng(j,r,h)if(a[j][i].v){
swap(a[r],a[j]);
break;
}
if(a[r][i].v==0)continue;
mint u=a[r][i].inv();
rep(j,h)if(j!=r){
//rng(j,r+1,h){ //for speed up (sweep に使った列に複数の non-zero があっても良い場合)
mint z=-a[j][i]*u;
rng(k,i,w)
a[j][k]+=a[r][k]*z;
}
r++;
}
return r;
}
void inverse(vvc<mint>&a,vvc<mint>&b){
int n=si(a);
rep(i,n){
assert(si(a[i])==n);
a[i].resize(2*n);
a[i][n+i]=1;
}
auto tmp=sweep(a,n);
assert(tmp==n);
b.resize(n);
rep(i,n){
b[i].resize(n);
mint w=a[i][i].inv();
rep(j,n)b[i][j]=a[i][n+j]*w;
}
}
void slv(){
int n,m;sc.read(n,m);
vvc<mint> a(n,vc<mint>(n)),b;
rep(i,n)a[i][i]=1;
int cnt=0;
auto getvert=[&](){
int v;sc.read(v);
v--;
return (v+cnt)%n;
};
rep(_,m){
int u=getvert();
int v=getvert();
a[u][v]-=rand_int(0,mint::mod-1);
}
inverse(a,b);
int q;sc.read(q);
vvc<mint> c,d;
rep(_,q){
int del;sc.read(del);
vi vs(del);
rep(i,del)vs[i]=getvert();
c.resize(del);
rep(i,del){
c[i].resize(del);
rep(j,del)c[i][j]=b[vs[i]][vs[j]];
}
inverse(c,d);
int ask;sc.read(ask);
rep(i,ask){
int s=getvert();
int t=getvert();
mint val=b[s][t];
rep(j,del)rep(k,del)val-=b[s][vs[j]]*d[j][k]*b[vs[k]][t];
int ans=bool(val);
pr.write(ans);
cnt+=ans;
}
pr.write('\n');
}
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(20);
//int t;cin>>t;rep(_,t)
slv();
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3444kb
input:
5 4 1 2 2 3 3 4 4 5 2 1 4 2 1 5 1 3 3 5 3 4 1 1 2
output:
01 1
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
100 4870 1 4 1 9 2 1 2 6 2 8 4 5 4 10 5 2 5 3 5 7 6 2 6 4 6 8 7 1 7 2 7 8 7 10 8 1 8 2 8 3 8 4 8 5 8 6 8 7 8 9 8 13 8 16 8 17 9 1 9 2 9 3 9 4 9 5 9 6 9 7 9 8 9 18 10 1 10 2 10 3 10 4 10 5 10 6 10 7 10 11 10 15 11 1 11 2 11 3 11 4 11 5 11 6 11 7 11 8 11 9 11 10 11 12 11 18 11 20 12 1 12 2 12 3 12 4 1...
output:
1011000010 1010110101 0001010000 0000101001 1000010000 0111001101 0011001101 1100010010 0001100010 0010110101 0011001111 0001000101 1101010010 0100001100 1000100001 0100000000 1110100000 0101111010 0111001001 1110000000 1011000011 0110000000 0000000100 0001011000 1000111000 1111000010 1000110000 011...
result:
ok 100 lines
Test #3:
score: 0
Accepted
time: 6ms
memory: 3820kb
input:
100 4839 1 2 1 7 1 12 1 13 1 15 1 17 1 21 1 22 1 24 2 1 2 4 2 5 2 7 2 12 2 16 2 19 2 22 2 24 3 7 3 8 3 13 3 20 3 22 4 8 4 12 4 14 4 19 5 2 5 3 5 4 5 6 5 7 5 10 5 13 5 14 5 19 5 24 6 3 6 7 6 8 6 10 6 12 6 13 6 15 6 17 6 19 6 21 6 23 6 24 7 2 7 6 7 8 7 9 7 10 7 12 7 13 7 16 7 23 8 1 8 9 8 11 8 12 8 13...
output:
1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111100111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 111...
result:
ok 100 lines
Test #4:
score: 0
Accepted
time: 6ms
memory: 3776kb
input:
100 4650 1 7 1 12 1 20 1 22 2 7 2 9 2 10 2 11 2 14 2 18 2 20 3 1 3 4 3 8 3 12 3 14 3 16 3 17 3 20 3 21 3 22 4 1 4 6 4 8 4 11 4 12 4 13 4 16 4 21 5 2 5 4 5 9 5 16 5 19 5 21 6 7 6 9 6 10 6 21 7 2 7 8 7 9 7 19 7 20 7 22 8 5 8 7 8 11 8 12 8 14 8 21 9 1 9 5 9 6 9 7 9 8 9 12 9 17 9 21 9 22 10 4 10 9 10 12...
output:
1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 111...
result:
ok 100 lines
Test #5:
score: 0
Accepted
time: 5ms
memory: 3772kb
input:
100 4945 1 2 1 3 1 5 1 7 1 8 1 9 1 10 1 13 1 15 2 1 2 3 2 4 2 9 2 11 2 12 2 15 3 1 3 10 3 12 3 16 4 1 4 5 4 10 4 12 4 13 4 15 4 16 5 6 5 11 5 16 5 17 6 2 6 10 6 11 6 14 7 1 7 2 7 3 7 4 7 5 7 6 7 8 7 9 7 10 7 11 7 16 7 21 7 22 7 23 7 24 7 25 7 27 7 28 7 30 7 31 7 32 7 35 7 38 7 39 8 1 8 2 8 3 8 4 8 5...
output:
1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1110101101 1111111111 1111111111 1111111111 1111111111 1100011011 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 111...
result:
ok 100 lines
Test #6:
score: 0
Accepted
time: 732ms
memory: 9420kb
input:
500 124582 1 12 1 14 2 4 2 7 2 9 2 13 2 14 2 18 3 1 3 4 3 7 3 14 3 17 4 1 4 3 4 6 4 12 4 15 4 18 5 3 6 1 6 3 6 8 6 10 6 11 6 13 6 15 6 17 6 18 7 3 7 4 7 5 7 8 7 9 7 17 8 2 8 6 9 10 9 13 9 17 10 2 10 5 10 17 11 1 11 2 11 3 11 4 11 5 11 6 11 7 11 8 11 9 11 10 11 17 11 18 11 19 11 26 12 1 12 2 12 3 12 ...
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 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 100000 lines
Test #7:
score: 0
Accepted
time: 744ms
memory: 9364kb
input:
500 125402 1 3 1 7 1 10 1 13 1 16 1 21 1 23 1 25 1 28 1 36 1 37 2 3 2 4 2 6 2 7 2 9 2 11 2 16 2 17 2 19 2 20 2 24 2 26 2 28 2 30 2 37 3 2 3 18 3 19 3 21 3 25 3 26 3 32 4 7 4 9 4 10 4 11 4 12 4 14 4 15 4 18 4 19 4 24 4 33 4 35 4 36 5 1 5 4 5 10 5 11 5 17 5 19 5 20 5 21 5 23 5 24 5 31 5 32 5 36 5 38 5...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 100000 lines
Test #8:
score: 0
Accepted
time: 730ms
memory: 9432kb
input:
500 123930 1 6 1 11 1 13 1 16 1 22 1 25 1 26 1 34 1 38 1 41 1 42 1 43 1 44 1 46 1 48 1 49 1 51 1 53 1 56 2 6 2 9 2 13 2 15 2 24 2 31 2 33 2 36 2 37 2 43 2 44 2 50 2 53 2 56 3 2 3 4 3 5 3 16 3 18 3 19 3 25 3 31 3 32 3 40 3 43 3 44 3 47 3 48 3 50 3 51 3 53 4 1 4 2 4 3 4 5 4 6 4 8 4 14 4 18 4 20 4 26 4...
output:
0 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 0 1 0 1 1 0 0 1 1 0 1 1 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 1 1 ...
result:
ok 100000 lines
Test #9:
score: 0
Accepted
time: 725ms
memory: 9404kb
input:
500 123484 1 5 1 8 1 10 1 11 1 12 1 20 1 23 1 26 1 27 1 28 1 29 1 31 1 33 1 41 2 4 2 7 2 10 2 18 2 20 2 34 2 35 2 39 2 41 2 42 2 44 2 46 2 52 3 4 3 5 3 6 3 7 3 9 3 14 3 17 3 19 3 23 3 25 3 26 3 32 3 36 3 38 3 39 3 40 3 44 3 46 3 48 3 51 4 1 4 7 4 11 4 12 4 14 4 16 4 17 4 19 4 21 4 23 4 24 4 25 4 29 ...
output:
0 0 1 1 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 0 0 0 1 1 1 0 0 1 1 0 0 0 1 1 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 0 0 0 1 0 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 1 0 0 1 0 0 0 1 0 1 0 ...
result:
ok 100000 lines
Test #10:
score: 0
Accepted
time: 2777ms
memory: 9360kb
input:
500 3278 2 5 2 7 3 5 4 6 4 9 5 6 5 7 5 8 6 8 6 9 6 10 7 8 7 9 8 9 9 13 9 20 9 22 9 23 9 24 9 27 9 29 9 31 10 12 10 14 10 17 10 21 10 23 10 24 10 25 10 26 10 27 11 15 11 17 11 20 11 21 11 25 12 16 12 20 12 21 12 22 12 24 12 28 12 32 12 33 12 39 12 42 12 45 12 46 12 47 12 48 13 14 13 20 13 21 13 23 13...
output:
1011111110 1010010110 0011111011 0101110101 0101011111 1111100001 1111111101 1110000110 1111111011 1111101011 1100101011 1110110111 1100111011 1110100100 1010011111 1111110111 0110111111 1111011100 1110011111 1001101000 1110100111 0111110111 1110111110 1101110001 1111010111 0100100011 1111010011 111...
result:
ok 400000 lines
Test #11:
score: 0
Accepted
time: 2792ms
memory: 9444kb
input:
500 3720 1 3 1 8 1 9 1 11 1 12 1 13 1 18 1 24 1 25 2 4 2 6 2 9 2 10 2 12 2 13 2 18 2 23 2 24 3 8 3 15 3 18 3 19 3 22 3 25 3 26 4 10 4 15 4 17 4 19 5 7 5 9 5 10 5 12 5 13 5 14 5 21 6 8 6 9 6 13 6 16 6 24 7 9 7 11 7 13 7 14 7 15 7 16 7 18 7 26 8 10 8 15 8 18 8 19 8 21 8 22 9 14 9 15 9 16 9 20 9 21 9 2...
output:
1111111101 1111111100 1110111110 1111111110 1111111111 1111111110 1101111011 1111111111 1111110111 1111111101 1111111111 0001010100 1111111111 1111111111 0011110111 1111111101 1111111111 1111111111 1110111111 1111111111 1011110011 1011111111 1111101101 1111111110 1111111111 1111111110 1111001111 110...
result:
ok 400000 lines
Test #12:
score: 0
Accepted
time: 2785ms
memory: 9436kb
input:
500 4232 1 2 1 6 1 14 1 16 2 4 2 6 2 10 2 16 2 17 2 18 2 25 2 26 2 28 3 4 3 6 3 12 3 13 3 17 3 18 3 25 4 8 4 12 4 18 4 23 4 28 5 8 5 9 5 10 5 12 5 13 5 17 5 18 5 21 5 26 5 28 6 8 6 9 6 12 6 23 6 24 6 25 6 26 6 27 6 29 7 15 7 23 7 24 7 25 7 28 8 12 8 14 8 16 8 19 8 29 9 12 9 13 9 15 9 16 9 17 9 20 9 ...
output:
1111011011 1111111111 1111111111 0111111011 1111111011 1110111111 0111111110 1110110111 1110001110 1011111111 0111111111 1111111111 1011111110 1111111111 1011111111 1111111111 1111011111 1111111011 1110111111 0111111111 0111110111 1111101111 0111110111 0111111111 1111111111 1111110011 1111111111 111...
result:
ok 400000 lines
Test #13:
score: 0
Accepted
time: 2776ms
memory: 9416kb
input:
500 6443 1 5 1 9 1 12 1 15 1 18 1 20 1 21 1 22 1 24 1 26 1 27 1 30 1 34 1 35 1 37 1 40 1 42 1 45 1 47 1 48 1 49 1 55 1 58 1 64 1 67 1 68 1 71 1 72 2 3 2 6 2 8 2 9 2 16 2 17 2 19 2 23 2 26 2 29 2 31 2 35 2 36 2 37 2 38 2 41 2 45 2 47 2 52 2 53 2 57 2 69 2 70 2 73 2 76 2 77 3 6 3 12 3 14 3 15 3 20 3 2...
output:
1001111111 0101111010 1111011111 1111111010 1111101111 0111111111 0110111111 1110111111 1111101101 1011111111 1111111111 1111111101 1110111110 1101111111 1011111111 1011111111 1111111111 1111110110 1111110101 1011111011 1111101110 1111111010 0011101101 1011111101 1111101111 1111100110 1101101000 111...
result:
ok 400000 lines
Test #14:
score: 0
Accepted
time: 2812ms
memory: 9364kb
input:
500 123824 2 4 2 6 3 1 3 10 4 2 4 6 4 7 4 8 5 2 5 3 5 4 5 7 5 8 5 11 6 7 7 3 7 5 7 6 7 8 7 11 8 2 8 4 9 1 9 2 9 3 9 4 9 5 9 6 9 7 9 8 9 12 9 14 9 17 9 21 9 23 9 24 9 25 9 26 9 27 10 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 13 10 15 10 18 10 19 10 23 11 1 11 2 11 3 11 4 11 5 11 6 11 7 11 8 11 10 11 15...
output:
0111110011 0110111111 1011001110 0101001011 0111110111 0011011000 1011110010 1000001101 1111000111 0101101111 1000001010 1010101010 0100000100 1011101110 1100011000 0000111110 0010100011 0110010101 1000111111 1101000001 0111110010 0011110100 0011101010 1001001111 0001010011 1010110110 0110111110 000...
result:
ok 400000 lines
Test #15:
score: 0
Accepted
time: 2794ms
memory: 9368kb
input:
500 124816 1 3 1 8 1 9 1 11 1 12 1 13 1 18 1 24 1 25 2 3 2 5 2 8 2 9 2 11 2 12 2 17 2 22 2 23 3 5 3 12 3 15 3 16 3 19 3 22 3 23 4 3 4 9 4 11 4 13 4 22 4 24 4 25 5 1 5 2 5 3 5 11 5 18 5 19 5 23 5 26 6 9 6 13 6 15 6 17 6 18 6 19 6 20 6 22 7 4 7 6 7 12 7 15 7 16 7 18 7 19 8 2 8 3 8 4 8 9 8 10 8 11 8 16...
output:
1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 111...
result:
ok 400000 lines
Test #16:
score: 0
Accepted
time: 2826ms
memory: 9508kb
input:
500 124872 1 2 1 6 1 14 1 16 2 1 2 4 2 6 2 10 2 16 2 17 2 18 2 25 2 26 2 28 3 1 3 2 3 5 3 11 3 12 3 16 3 17 3 24 4 1 4 5 4 9 4 15 4 20 4 25 4 30 5 1 5 2 5 3 5 6 5 7 5 11 5 12 5 15 5 20 5 22 5 26 5 27 5 30 6 1 6 13 6 14 6 15 6 16 6 17 6 19 6 28 7 1 7 8 7 9 7 10 7 13 7 19 7 21 7 23 7 26 8 1 8 7 8 12 8...
output:
0001111111 1101111010 1110011011 1011001101 0110111111 0000111000 1101010111 0101001111 1001101011 1111111101 1111110011 0010011010 0001000001 0101101111 1111000101 1100100001 0011010101 1010010110 0011111011 0000011011 1100010000 1011011011 1111010001 0110111011 0111000111 0111111000 1111000111 011...
result:
ok 400000 lines
Test #17:
score: 0
Accepted
time: 2774ms
memory: 9404kb
input:
500 124293 1 5 1 9 1 12 1 15 1 18 1 20 1 21 1 22 1 24 1 26 1 27 1 30 1 34 1 35 1 37 1 40 1 42 1 45 1 47 1 48 1 49 1 55 1 58 1 64 1 67 1 68 1 71 1 72 2 1 2 5 2 7 2 8 2 15 2 16 2 18 2 22 2 25 2 28 2 30 2 34 2 35 2 36 2 37 2 40 2 44 2 46 2 51 2 52 2 56 2 68 2 69 2 72 2 75 2 76 3 2 3 9 3 11 3 12 3 17 3 ...
output:
1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111111 1111111101 1111111111 1111111111 1111111111 1111111111 1100100100 1111111111 1111111111 1111111111 111...
result:
ok 400000 lines