QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#512830#9170. Cycle Gameucup-team112#AC ✓228ms12028kbC++2012.7kb2024-08-10 15:59:372024-08-10 15:59:39

Judging History

你现在查看的是最新测评结果

  • [2024-08-10 15:59:39]
  • 评测
  • 测评结果:AC
  • 用时:228ms
  • 内存:12028kb
  • [2024-08-10 15:59:37]
  • 提交

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--)

namespace template_tute{
  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<ll>({a,b,c})-min<ll>({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;}
  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;}
  std::ostream &operator<<(std::ostream &dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
      __uint128_t tmp = value < 0 ? -value : value;
      char buffer[128];
      char *d = std::end(buffer);
      do {
        --d;
        *d = "0123456789"[tmp % 10];
        tmp /= 10;
      } while (tmp != 0);
      if (value < 0) {
        --d;
        *d = '-';
      }
      int len = std::end(buffer) - d;
      if (dest.rdbuf()->sputn(d, len) != len) {
        dest.setstate(std::ios_base::badbit);
      }
    }
    return dest;
  }
  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;
  }
}
using namespace template_tute;


struct UnionFind {
  vector<ll> data;
  ll num;
  UnionFind(ll size) : data(size, -1) ,num(size){ }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
	  num--;
    }
    return x != y;
  }
  bool find(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(int x) {
    return -data[root(x)];
  }
  vector<vector<int>>groups(){
    vector<vector<int>>ret(data.size());
    for(int i=0;i<data.size();i++){
      ret[root(i)].push_back(i);
    }
    return ret;
  }
  void print(){
    auto tmp=groups();
    for(int i=0;i<data.size();i++){
      if(!tmp[i].empty()){
        for(auto z:tmp[i])cout<<z<<",";
        cout<<endl;
      }
    }
  }
};

void solve(){
	ll res=0,buf=0;
  bool judge = true;

  ll h,w;cin>>h>>w;
  ll k;cin>>k;
  UnionFind uf(h*w);
  string ret;
  vector<string>s(h,string(w,'0'));
  while(k--){
    ll x,y;cin>>x>>y;x--;y--;
    if(s[x][y]=='1'){
      ret+='1';
    }
    else{
      vector<string>sh(3,string(3,'0'));
      rep(i,-1,2)rep(j,-1,2){
        if(0<=x+i&&x+i<h&&0<=y+j&&y+j<w&&s[x+i][y+j]=='1'){
          sh[i+1][j+1]='1';
        }
      }
      UnionFind uf2(3*3);
      
      rep(i,0,3)rep(j,0,3){
        if(sh[i][j]=='1'){
          rep(k,0,4){
            ll nx=i+dx[k],ny=j+dy[k];
            if(0<=nx&&nx<3&&0<=ny&&ny<3&&sh[nx][ny]=='1'){
              uf2.unite(i*3+j,nx*3+ny);
            }
          }
        }
      }
      vector<P>p;
      rep(o,0,4){
        ll nx=x+dx[o],ny=y+dy[o];
        ll nx2=dx[o]+1,ny2=dy[o]+1;
        if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='1'){
          p.EB(nx*w+ny,nx2*3+ny2);
        }
      }
      bool ok=true;
      rep(i,0,p.size())rep(j,i+1,p.size()){
        if(uf.find(p[i].fi,p[j].fi)&&!uf2.find(p[i].se,p[j].se)){
          ok=false;
        }
      }
      rep(i,0,3)rep(j,0,3){
        ll cnt=0;
        rep(di,0,3)rep(dj,0,3){
          ll nx=x-i+di,ny=y-j+dj;
          if(nx==x&&ny==y){
            cnt++;
            continue;
          }
          if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='1'){
            cnt++;
          }
        }
        OUT(i,j,cnt);
        if(cnt==9)ok=false;
      }
      if(ok)ret+='1';
      else ret+='0';
    }
    if(ret.back()=='1'){
      s[x][y]='1';
      rep(i,0,4){
        ll nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='1'){
          uf.unite(x*w+y,nx*w+ny);
        }
      }
    }
    //rep(x,0,h)OUT(s[x]);cout<<endl;
  }
  cout<<ret<<endl;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  int T = 1;
  //cin>>T;
  while(T--){
    solve();
  }
  return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

4 3 7
2 1
2 2
2 3
3 1
3 2
4 1
4 2

output:

1111111

result:

ok "1111111"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

3 3 8
1 1
1 2
1 3
2 3
3 3
3 2
3 1
2 1

output:

11111110

result:

ok "11111110"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

10 10 7
9 1
6 6
3 8
8 7
5 10
1 7
1 2

output:

1111111

result:

ok "1111111"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

9 10 50
1 9
1 6
2 3
3 1
7 4
9 4
1 3
2 5
9 2
7 9
5 6
8 10
9 5
5 5
4 10
9 7
5 9
3 2
4 5
1 1
4 7
3 6
2 8
4 3
8 6
5 10
4 8
5 4
7 2
9 6
4 2
7 8
5 2
3 5
9 1
6 1
1 5
9 9
5 8
6 3
8 8
8 4
7 7
7 1
3 7
2 2
3 10
6 9
8 3
7 6

output:

11111111111111111111111111111111111111111111111111

result:

ok "11111111111111111111111111111111111111111111111111"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

3 5 11
1 5
2 4
1 2
1 3
3 3
3 1
3 4
2 3
1 4
2 1
2 5

output:

11111111111

result:

ok "11111111111"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

7 9 12
7 3
2 3
6 2
2 2
4 2
2 8
5 7
4 4
6 8
2 7
7 2
1 9

output:

111111111111

result:

ok "111111111111"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

1 4 1
1 2

output:

1

result:

ok "1"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

9 8 67
5 5
8 3
9 5
7 4
5 1
9 3
4 2
2 5
1 7
7 8
7 2
8 5
6 1
8 8
4 4
5 4
1 5
3 4
6 7
2 3
3 7
5 7
2 4
2 7
1 3
7 3
2 8
6 6
6 2
6 3
7 5
9 6
7 6
3 6
1 1
6 4
3 1
5 3
8 7
2 1
4 1
8 4
8 6
3 5
5 8
1 6
1 2
4 6
9 4
1 4
3 3
4 8
8 1
4 7
9 8
3 8
6 5
6 8
3 2
2 2
7 1
9 2
4 3
1 8
4 5
8 2
7 7

output:

1111111111111111111111111111111111111111111110010101101000101101101

result:

ok "111111111111111111111111111111...1111111110010101101000101101101"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

3 10 3
3 9
2 5
2 7

output:

111

result:

ok "111"

Test #10:

score: 0
Accepted
time: 7ms
memory: 12028kb

input:

222212 1 21562
105762 1
167947 1
127551 1
117618 1
174844 1
139867 1
156729 1
30554 1
54488 1
151832 1
132914 1
109432 1
212091 1
136499 1
17818 1
48806 1
95752 1
66607 1
39930 1
23054 1
160823 1
169054 1
96680 1
150677 1
52895 1
93103 1
118079 1
79155 1
194811 1
141874 1
138763 1
2600 1
121471 1
17...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #11:

score: 0
Accepted
time: 46ms
memory: 4980kb

input:

1 167058 126088
1 15282
1 63796
1 77270
1 88793
1 42787
1 129851
1 34468
1 74525
1 121105
1 157182
1 92736
1 102044
1 11284
1 23439
1 142720
1 128610
1 27437
1 105575
1 130827
1 152824
1 76358
1 152954
1 65509
1 139802
1 66299
1 108943
1 140446
1 112411
1 95814
1 115750
1 9667
1 55383
1 89323
1 6734...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #12:

score: 0
Accepted
time: 68ms
memory: 4452kb

input:

9 12788 86384
4 11931
2 8183
1 5816
7 10320
8 5754
4 10778
4 12280
7 12746
1 4699
3 7876
4 3044
2 4903
9 10252
8 10512
7 6546
8 1338
5 9700
1 9833
6 11315
2 4067
7 9350
9 8200
2 1718
1 2542
2 4596
9 367
5 12426
1 12166
5 7652
4 2316
9 1946
3 6187
4 3306
1 63
8 4132
3 12491
2 3951
8 4169
7 11801
9 46...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0010111100011000000100110101100"

Test #13:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

10 6 58
7 3
1 5
9 2
10 4
1 2
1 6
9 6
5 4
8 2
9 3
5 1
4 5
7 4
10 1
10 3
5 3
4 3
6 5
1 4
7 2
10 6
8 3
5 6
9 4
2 2
1 1
6 4
3 5
3 2
6 2
3 6
8 1
8 4
8 5
7 5
6 1
4 4
3 4
3 1
7 1
4 1
2 4
6 6
9 5
7 6
2 1
5 5
10 2
2 5
4 2
2 6
10 5
9 1
4 6
5 2
6 3
1 3
8 6

output:

1111111111111111111111111111111101111111111011011001000000

result:

ok "1111111111111111111111111111111101111111111011011001000000"

Test #14:

score: 0
Accepted
time: 0ms
memory: 4440kb

input:

23660 2 4698
10158 1
1229 1
51 2
10559 2
15495 2
19343 1
18458 1
19633 2
23151 1
11738 2
21366 1
12968 2
10474 1
10552 2
8067 2
7125 2
14643 1
7579 2
21608 2
7067 2
20400 1
14397 2
21474 2
8294 2
1332 1
18105 1
2285 1
1223 1
13429 2
18580 2
11156 2
5498 1
6830 1
8848 2
21334 2
11946 1
10177 1
5349 1...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #15:

score: 0
Accepted
time: 25ms
memory: 3740kb

input:

51 732 29706
14 458
6 600
18 452
43 262
24 685
51 192
14 248
50 672
16 65
45 191
25 196
1 447
4 574
32 493
16 100
39 715
17 397
37 644
32 580
32 622
22 160
20 694
29 120
30 302
7 283
18 290
51 420
20 553
42 681
11 724
26 528
50 497
46 500
3 534
36 58
42 167
18 534
1 654
50 276
37 386
19 649
14 41
8 ...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0100001111101110110110000010000"

Test #16:

score: 0
Accepted
time: 162ms
memory: 8320kb

input:

75000 4 225000
71753 3
13211 2
61737 3
59039 3
3674 3
50461 4
12758 3
69966 1
57525 1
42178 1
15054 1
66939 2
2798 4
74983 2
7250 2
2247 4
11438 1
67858 4
66527 2
21625 2
14111 2
28737 1
7431 4
11317 3
47421 2
51295 4
39591 4
20811 3
51582 3
47874 2
3238 2
10987 3
1225 1
58741 4
2141 3
35454 4
5021 ...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1101011111100100010101000000000"

Test #17:

score: 0
Accepted
time: 158ms
memory: 9192kb

input:

100000 3 240000
63826 2
25561 1
24122 3
56762 3
66822 2
24467 2
5419 1
59533 2
71406 2
62274 1
63084 1
33262 3
16614 2
71724 1
99182 1
3574 3
2804 2
40022 2
90379 1
44898 2
59169 3
55663 1
79971 2
30606 3
58613 3
38992 3
51702 1
10168 3
44411 3
39048 1
25384 2
276 1
68607 1
34137 1
72641 2
92427 1
9...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0101001000001000101001011110010"

Test #18:

score: 0
Accepted
time: 195ms
memory: 8020kb

input:

60000 5 250000
19905 3
6687 2
7727 4
23854 3
1329 4
45419 4
15116 1
35612 4
11560 1
16969 5
43328 4
30175 2
1587 5
15890 1
53896 3
43465 4
26642 2
3443 5
6697 5
6489 3
44351 2
48037 2
39926 5
974 1
20783 2
51437 4
31394 2
33663 2
26261 5
49301 4
2074 1
16999 4
48098 5
28754 4
27961 3
614 5
57608 2
5...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0010100101111000100000011001011"

Test #19:

score: 0
Accepted
time: 188ms
memory: 9228kb

input:

100000 3 270000
50999 2
78476 3
21423 1
26134 3
69234 1
48259 3
40043 1
92586 1
96544 3
65679 1
63139 1
79464 2
76129 3
3836 3
65093 1
81997 3
13905 2
82341 2
32201 1
42796 2
69216 3
14753 3
50176 3
66724 2
21607 3
9619 2
96579 1
59856 2
5086 1
89747 1
4122 3
8806 3
57529 2
6476 3
6689 2
97261 1
936...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0000011010000000010100010001010"

Test #20:

score: 0
Accepted
time: 228ms
memory: 7024kb

input:

29997 10 272700
22251 10
4359 10
3780 4
23168 10
19310 8
784 2
21855 1
19914 4
279 9
26868 6
11534 3
17252 8
10865 2
15782 3
10134 4
17047 4
8318 5
11552 4
21333 1
2023 10
17397 5
13151 3
21068 3
1171 3
21112 4
23374 4
289 8
9248 3
19337 3
10005 7
16909 2
14103 5
3098 8
23534 3
7782 1
4765 7
10294 8...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1100000010000000010000000100010"

Test #21:

score: 0
Accepted
time: 69ms
memory: 6980kb

input:

30000 10 180008
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 ...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111110111111101111111011111111"

Test #22:

score: 0
Accepted
time: 91ms
memory: 9200kb

input:

100000 3 250001
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 ...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0000000000000000000000000000001"

Test #23:

score: 0
Accepted
time: 55ms
memory: 6220kb

input:

300 1000 151298
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 ...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #24:

score: 0
Accepted
time: 215ms
memory: 6584kb

input:

1000 300 300000
1 1
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 1...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0000001001001100100000110100001"

Test #25:

score: 0
Accepted
time: 214ms
memory: 7112kb

input:

30000 10 300000
1 1
1 3
1 5
1 7
1 9
3 1
3 3
3 5
3 7
3 9
5 1
5 3
5 5
5 7
5 9
7 1
7 3
7 5
7 7
7 9
9 1
9 3
9 5
9 7
9 9
11 1
11 3
11 5
11 7
11 9
13 1
13 3
13 5
13 7
13 9
15 1
15 3
15 5
15 7
15 9
17 1
17 3
17 5
17 7
17 9
19 1
19 3
19 5
19 7
19 9
21 1
21 3
21 5
21 7
21 9
23 1
23 3
23 5
23 7
23 9
25 1
25 3...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0001000000000000100000000010000"

Extra Test:

score: 0
Extra Test Passed