QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#220308#5093. 会议hos_lyric0 2ms8712kbC++148.3kb2023-10-20 06:47:592023-10-20 06:47:59

Judging History

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

  • [2023-10-20 06:47:59]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:8712kb
  • [2023-10-20 06:47:59]
  • 提交

answer

#include "majority.h"

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

namespace {
using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")

template <class T> struct SplaySimple {
  SplaySimple *p, *l, *r;
  T t;
  SplaySimple() : p(nullptr), l(nullptr), r(nullptr), t() {}
  void rotate() {
    if (p->l == this) { if (r) { r->p = p; } p->l = r; r = p; }
    else              { if (l) { l->p = p; } p->r = l; l = p; }
    SplaySimple *pp = p->p;
    if (pp) ((pp->l == p) ? pp->l : pp->r) = this;
    p->p = this; p = pp;
  }
  SplaySimple *splay() {
    for (; p; rotate()) if (p->p) ((p->l == this) == (p->p->l == p)) ? p->rotate() : rotate();
    return this;
  }
  SplaySimple *linkL(SplaySimple *a) { assert(!l); l = a; if (l) { l->p = this; } return this; }
  SplaySimple *linkR(SplaySimple *a) { assert(!r); r = a; if (r) { r->p = this; } return this; }
  SplaySimple *cutL() { if (l) { l->p = nullptr; l = nullptr; } return this; }
  SplaySimple *cutR() { if (r) { r->p = nullptr; r = nullptr; } return this; }
  SplaySimple *leftmost() {
    SplaySimple *a = this;
    for (; a->l; a = a->l) {}
    return a->splay();
  }
  SplaySimple *rightmost() {
    SplaySimple *a = this;
    for (; a->r; a = a->r) {}
    return a->splay();
  }
  template <class F> void dfs(F f) {
    if (l) l->dfs(f);
    f(this);
    if (r) r->dfs(f);
  }
  friend SplaySimple *concat(SplaySimple *a, SplaySimple *b) {
    if (!a) return b;
    if (!b) return a;
    return a->splay()->rightmost()->linkR(b->splay());
  }
};

////////////////////////////////////////////////////////////////////////////////

struct Node;
using Tree = SplaySimple<Node>;
struct Node {
  Tree *l1, *r1;
  D_t val;
  Node() : l1(nullptr), r1(nullptr), val(-1) {}
};

int Q = 0;
Tree nodes[100'010];

// path: pointer to the rightmost node on the path
// rems: pointer to the root of the tree for the remaining nodes
Tree *path = nullptr, *rems = nullptr;

bool answer() {
/*
vector<Tree *>as;
for(Tree*a=path;a;a=a->t.l1)as.push_back(a);
reverse(as.begin(),as.end());
cerr<<"path = ";for(Tree*a:as)cerr<<make_pair(a-nodes,a->t.val.get_value())<<" ";cerr<<endl;
cerr<<"rems = ";if(rems)rems->dfs([&](Tree*a)->void{cerr<<make_pair(a-nodes,a->t.val.get_value())<<" ";});cerr<<endl;
for(int q=1;q<=Q;++q)if(!nodes[q].p&&(nodes[q].l||nodes[q].r)){
 cerr<<"  chain ";nodes[q].dfs([&](Tree*a)->void{cerr<<make_pair(a-nodes,a->t.val.get_value())<<" ";});cerr<<endl;
}
for(int q=1;q<=Q;++q)if(nodes[q].t.l1)assert(nodes[q].t.l1->t.r1==&nodes[q]);
for(int q=1;q<=Q;++q)if(nodes[q].t.r1)assert(nodes[q].t.r1->t.l1==&nodes[q]);
for(int q=1;q<=Q;++q)if(nodes[q].p)assert(nodes[q].p->l==&nodes[q]||nodes[q].p->r==&nodes[q]);
for(int q=1;q<=Q;++q)if(nodes[q].l)assert(nodes[q].l->p==&nodes[q]);
for(int q=1;q<=Q;++q)if(nodes[q].r)assert(nodes[q].r->p==&nodes[q]);
//*/
  if (path) {
    if (!path->splay()->leftmost()->t.l1) {
      submit(path->t.val);
      return true;
    } else {
      assert(!rems);
      return false;
    }
  } else {
    assert(!rems);
    return false;
  }
}

void insertBetw(Tree *l, Tree *r, Tree *a) {
  if (l) l->t.r1 = a;
  a->t.l1 = l;
  a->t.r1 = r;
  if (r) r->t.l1 = a;
}
void checkL2(Tree *a, bool ask) {
  if (!ask || (a->t.l1 && a->t.l1->t.l1 && a->t.l1->t.l1->t.val == a->t.val)) {
    concat(a->t.l1->t.l1, a);
  }
}
void checkR2(Tree *a, bool ask) {
  if (!ask || (a->t.r1 && a->t.r1->t.r1 && a->t.val == a->t.r1->t.r1->t.val)) {
    concat(a, a->t.r1->t.r1);
  }
}
}  // namespace

bool insert(const D_t &val) {
  Tree *a = &nodes[++Q];
  a->t.val = val;
// cerr<<COLOR("33")<<"insert "<<make_pair(a-nodes,a->t.val.get_value())<<COLOR()<<endl;
  if (path) {
    if (path->t.val == a->t.val) {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
      Tree *b = path->splay()->leftmost();
      if (b->t.l1) {
        insertBetw(b->t.l1->t.l1, b->t.l1, a);
        a->t.r1->splay()->cutL();
        checkL2(a, true);
        checkR2(a, false);
      } else {
        rems = concat(rems, a);
      }
    } else {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
      path->t.r1 = a;
      a->t.l1 = path;
      checkL2(a, true);
      path = a;
      if (rems) {
        Tree *b = rems;
        {
          Tree *l = b->l, *r = b->r;
          b->cutL()->cutR();
          rems = concat(l, r);
        }
        path->t.r1 = b;
        b->t.l1 = path;
        concat(path->t.l1, b);
        path = b;
      }
    }
  } else {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
    path = a;
  }
  return answer();
}

bool erase(int id) {
  Tree *a = &nodes[id];
// cerr<<COLOR("33")<<"erase "<<make_pair(a-nodes,a->t.val.get_value())<<COLOR()<<endl;
  if (!a->t.l1 && !a->t.r1 && a != path) {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
    a->splay();
    Tree *l = a->l, *r = a->r;
    a->cutL()->cutR();
    rems = concat(l, r);
  } else {
    if (rems && !a->splay()->leftmost()->t.l1) {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
      Tree *b = rems;
      {
        Tree *l = b->l, *r = b->r;
        b->cutL()->cutR();
        rems = concat(l, r);
      }
      if (a->t.l1) a->t.l1->t.r1 = b;
      if (a->t.r1) a->t.r1->t.l1 = b;
      b->t.l1 = a->t.l1;
      b->t.r1 = a->t.r1;
      {
        a->splay();
        Tree *l = a->l, *r = a->r;
        a->cutL()->cutR();
        b->linkL(l)->linkR(r);
      }
    } else {
      Tree *b = a->t.l1;
      Tree *c = a->t.r1;
      if (b && c && b->splay()->r) {
        Tree *d = b->splay()->leftmost();
        Tree *e = c->splay()->rightmost();
        if (b->t.l1) b->t.l1->t.r1 = c;
        c->t.l1 = b->t.l1;
        {
          a->splay();
          Tree *l = a->l, *r = a->r;
          a->cutL()->cutR();
          concat(l, r);
        }
        {
          b->splay();
          Tree *l = b->l, *r = b->r;
          b->cutL()->cutR();
          concat(l, r);
        }
        {
          Tree *f = c->t.r1;
          if (f && !f->splay()->l) {
            checkL2(f, true);
          }
        }
        if (d->t.l1) {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
          insertBetw(d->t.l1->t.l1, d->t.l1, b);
          b->t.r1->splay()->cutL();
          checkL2(b, true);
          checkR2(b, false);
        } else if (e->t.r1) {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
          insertBetw(e->t.r1, e->t.r1->t.r1, b);
          b->t.l1->splay()->cutR();
          checkL2(b, false);
          checkR2(b, true);
          if (!b->t.r1) path = b;
        } else {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
          rems = concat(rems, b);
          b->t.l1 = b->t.r1 = nullptr;
        }
      } else {
// cerr<<COLOR("32")<<"Case "<<__LINE__<<COLOR()<<endl;
        a->splay()->cutL()->cutR();
        if (b) b->t.r1 = c;
        if (c) c->t.l1 = b;
        if (b && c) {
          if (b->t.l1 && b->t.l1->t.val == c->t.val) concat(b->t.l1, c);
          if (c->t.r1 && b->t.val == c->t.r1->t.val) concat(b, c->t.r1);
        }
        if (!c) path = b;
      }
    }
  }
  a->t.l1 = a->t.r1 = nullptr;
  return answer();
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 1
Acceptable Answer
time: 0ms
memory: 8516kb

input:

1
100
0 4
0 4
0 1
1 1
0 2
0 2
1 3
1 2
0 2
1 5
0 2
0 3
0 3
0 4
1 8
1 9
1 6
0 1
0 2
0 1
1 11
1 12
0 2
1 13
1 14
1 4
0 2
1 15
0 3
1 16
0 4
0 2
0 2
1 17
1 19
1 7
0 3
1 20
0 4
1 21
0 4
1 22
0 1
0 3
1 23
1 24
0 3
1 25
0 1
0 4
1 26
1 27
0 4
0 1
1 29
1 28
0 4
1 30
0 1
0 3
0 4
0 4
0 3
0 2
1 34
0 4
0 4
0 3
1 ...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 4
1 4
1 4
0 -1
0 -1
0 -1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
0 -1
1 2
1 2
1 2
0 -1
1 2
0 -1
1 2
0 -1
1 2
1 2
1 2
0 -1
1 2
0 -1
0 -1
0 -1
1 4
0 -1
1 2
1 2
1 2
0 -1
0 -1
0 -1
1 4
0 -1
1 4
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 4
0 ...

result:

points 0.50 second question correct

Test #2:

score: 2
Accepted
time: 1ms
memory: 8712kb

input:

1
100
0 1
0 1
0 1
0 2
1 3
0 1
0 1
1 5
0 2
0 2
0 2
1 9
0 1
1 1
0 2
0 2
1 11
1 10
1 12
1 8
1 4
1 6
0 2
1 13
0 1
1 14
0 2
1 15
0 1
0 2
1 16
0 1
0 2
1 19
1 18
0 1
1 20
1 17
0 1
1 21
0 1
0 2
1 22
1 2
0 1
1 24
0 2
1 25
0 2
1 26
0 1
0 2
0 1
1 29
1 28
1 27
0 2
1 30
0 1
1 31
0 1
1 32
0 1
1 33
0 2
0 1
1 35
0 ...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
0 -1
1 2
0 -1
1 1
0 -1
1 2
1 2
1 2
1 2
1 2
0 -1
1 1
0 -1
1 2
0 -1
1 1
0 -1
1 2
0 -1
1 1
0 -1
1 2
0 -1
1 2
0 -1
1 2
0 -1
1 2
0 -1
1 1
0 -1
1 1
0 -1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
...

result:

ok both questions correct

Test #3:

score: 2
Accepted
time: 0ms
memory: 8484kb

input:

1
100
0 3
0 2
0 3
1 2
0 1
0 2
0 1
0 1
1 7
1 3
0 2
1 8
1 4
0 1
1 9
1 5
0 2
0 1
0 1
0 3
0 4
0 4
1 15
1 10
0 3
0 3
1 17
1 16
0 1
0 3
1 18
1 13
0 1
1 20
0 3
1 21
1 12
0 2
0 2
1 23
0 2
0 3
0 2
1 24
0 1
0 2
0 1
0 1
0 3
1 27
0 1
1 32
0 1
0 3
0 1
1 35
1 28
1 34
0 2
1 30
1 31
0 2
0 1
0 2
0 1
0 1
0 1
1 37
0 2...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 3
0 -1
1 3
1 3
1 3
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 1
0 -1
0 -1
0 -1
1 1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -...

result:

ok both questions correct

Test #4:

score: 2
Accepted
time: 0ms
memory: 8428kb

input:

1
100
0 3
0 2
0 1
1 3
0 1
1 2
0 1
1 5
0 2
1 6
0 1
0 2
1 8
0 1
1 9
0 4
0 1
1 10
1 11
0 2
1 12
1 4
0 3
1 13
0 1
1 14
0 1
1 15
0 1
0 4
0 4
0 1
1 19
0 2
0 1
0 1
1 21
0 2
0 1
0 1
0 1
1 25
1 23
1 24
0 1
1 27
1 26
1 16
1 18
0 3
0 1
0 1
0 2
0 1
1 30
0 2
0 1
1 28
1 34
0 1
1 32
0 1
1 35
1 29
1 36
1 7
0 1
0 1
...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 3
0 -1
0 -1
0 -1
0 -1
0 -1
1 1
0 -1
0 -1
0 -1
1 1
0 -1
1 1
1 1
1 1
0 -1
1 1
1 1
1 1
0 -1
1 1
0 -1
1 3
0 -1
1 1
0 -1
1 1
0 -1
1 1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 1
0 -1
1 1
0 -1
1 1
0 -1
0 -1
0 -1
0 -1
0 -...

result:

ok both questions correct

Test #5:

score: 2
Accepted
time: 2ms
memory: 8416kb

input:

1
100
0 5
0 2
0 5
1 3
0 2
1 2
0 3
1 4
0 1
0 6
0 7
1 6
1 8
0 6
1 9
0 3
0 2
1 10
1 11
0 2
1 5
1 1
0 2
0 4
0 5
1 15
1 14
1 12
0 5
0 2
1 16
0 6
0 1
1 19
0 3
0 5
0 7
1 21
1 22
0 2
0 1
1 24
1 23
0 5
1 7
1 17
1 20
1 25
0 3
1 26
0 5
0 6
0 1
1 27
1 28
0 3
0 3
1 30
1 31
0 1
0 5
0 2
1 33
1 34
0 1
1 35
1 29
1 3...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 5
0 -1
1 5
0 -1
1 2
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 2
0 -1
0 -1
0 -1
1 2
0 -1
0 -1
0 -1
1 2
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 ...

result:

ok both questions correct

Test #6:

score: 2
Accepted
time: 1ms
memory: 8376kb

input:

1
100
0 1
0 3
0 3
1 3
0 8
1 4
0 5
1 5
0 3
0 5
1 7
1 6
0 5
0 4
0 8
1 9
0 1
1 10
0 6
0 1
1 13
1 12
1 11
1 8
0 7
1 14
0 3
0 4
0 1
1 17
1 15
1 16
0 1
0 7
1 18
1 19
0 8
1 20
0 6
1 21
0 4
0 6
1 22
0 3
0 3
1 24
1 25
0 1
0 7
1 26
0 4
1 28
1 27
0 2
0 6
1 29
0 2
1 30
0 5
0 6
0 4
1 34
1 33
1 32
0 7
0 2
0 1
1 3...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 1
0 -1
1 3
0 -1
0 -1
0 -1
0 -1
0 -1
1 3
0 -1
1 3
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 3
0 -1
0 -1
0 -1
0 -1
0 -1
1 1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 3
0 -1
0 -1
0 -...

result:

ok both questions correct

Test #7:

score: 2
Accepted
time: 0ms
memory: 8428kb

input:

1
100
0 5
0 5
0 7
1 1
0 5
1 2
0 2
0 9
1 6
1 4
0 10
0 6
1 8
1 5
0 7
1 9
0 4
0 6
0 10
0 1
0 5
1 12
0 3
1 11
0 6
0 6
1 15
1 13
0 8
1 17
1 16
0 7
1 14
1 18
1 7
0 1
0 13
0 5
1 22
0 9
1 23
1 20
0 4
0 11
1 24
1 25
1 10
1 21
0 2
1 26
0 13
0 10
0 4
0 2
1 28
1 29
1 30
1 27
0 1
1 31
0 2
1 32
0 13
1 33
0 9
1 34...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 5
1 5
1 5
0 -1
1 5
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 7
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 7
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 7
1 7...

result:

ok both questions correct

Test #8:

score: 2
Accepted
time: 0ms
memory: 8480kb

input:

1
100
0 5
0 12
0 2
1 2
0 1
0 2
1 1
0 1
0 7
1 5
0 3
1 4
1 8
0 6
0 1
1 9
1 3
1 7
0 4
0 3
0 2
0 4
0 1
1 13
0 1
1 14
1 12
0 9
1 17
1 15
0 7
0 2
0 1
0 6
0 1
0 4
1 21
0 1
0 10
1 24
1 22
1 23
1 11
0 1
1 20
0 8
0 10
0 2
0 1
1 27
1 30
0 4
1 31
1 28
0 6
1 32
0 13
1 29
1 16
1 18
1 26
0 12
1 34
1 6
1 10
0 10
0 ...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 5
0 -1
0 -1
0 -1
0 -1
0 -1
1 2
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 1
1 1
1 1
0 -1
0 -1
0 -1
0 -1
0 -1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
0 -1
1 1
0 -1
1 1
0 -1
1 1
1 1
1 1
0 -1
0 -1
0 -1
1 1
1 1
1 1
0 -1
0 -1
0 -1
0 -1
0 -1
0...

result:

ok both questions correct

Test #9:

score: 2
Accepted
time: 1ms
memory: 8544kb

input:

1
100
0 14
0 14
0 14
1 3
0 7
1 4
0 18
0 21
0 18
1 7
1 5
0 17
0 24
0 11
1 6
0 7
0 8
0 3
1 1
1 13
1 10
0 7
0 3
0 24
0 19
0 9
0 13
0 1
1 20
0 17
1 21
0 24
0 1
1 16
0 25
1 22
1 14
1 24
0 16
0 10
1 25
1 15
0 3
0 6
1 9
1 27
1 8
1 18
0 14
0 24
1 29
1 30
1 28
1 12
0 9
1 31
1 23
0 2
0 15
1 32
0 1
1 34
0 10
1...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 14
1 14
1 14
1 14
1 14
1 14
1 14
0 -1
0 -1
0 -1
1 14
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0...

result:

ok both questions correct

Test #10:

score: 2
Accepted
time: 1ms
memory: 8428kb

input:

1
100
0 1
0 1
0 16
1 2
0 19
0 4
1 5
0 19
0 7
1 7
0 7
0 15
1 8
0 9
0 5
1 10
1 9
0 3
0 12
1 12
1 11
0 5
0 8
0 9
1 14
0 1
1 16
0 2
0 3
1 19
0 5
1 18
1 20
0 10
0 4
1 21
1 22
1 4
1 3
0 9
0 1
1 23
0 11
0 2
0 6
0 12
0 17
0 13
1 25
0 11
1 31
0 8
0 17
0 5
0 8
0 15
0 10
0 3
1 37
0 16
0 5
0 6
0 5
1 42
0 12
1 4...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 1
1 1
1 1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1...

result:

ok both questions correct

Test #11:

score: 1
Acceptable Answer
time: 0ms
memory: 8680kb

input:

1
100
0 2
0 4
0 4
1 3
0 4
0 4
0 3
1 6
1 2
0 3
1 7
1 1
0 4
0 4
0 2
0 3
0 4
1 8
1 10
0 3
1 9
0 4
0 3
0 3
0 4
0 4
0 3
1 15
0 4
1 14
1 16
1 12
0 4
1 5
1 21
1 4
0 3
0 4
0 4
0 4
0 3
1 23
1 24
0 3
0 4
0 2
1 26
1 27
0 4
1 30
0 4
0 4
0 3
1 22
1 33
1 32
1 31
1 28
0 4
1 34
1 11
1 13
1 18
0 2
0 4
0 3
0 2
1 35
0...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 2
0 -1
1 4
0 -1
1 4
1 4
1 4
1 4
1 4
0 -1
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
0 -1
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 4
0 -1
1 3
0 -1
1 4
1 4
1 4
0 -1
1 3
1 3
1 3
0 -1
0 -1
0 -1
1 4
0 -1
1 4
1 4
1 4
1 4
1 4
...

result:

points 0.50 second question correct

Test #12:

score: 2
Accepted
time: 1ms
memory: 8424kb

input:

1
100
0 4
0 2
0 1
1 2
0 2
0 1
0 4
0 1
1 5
0 3
1 6
1 7
0 1
1 9
0 1
1 10
0 2
0 2
0 2
0 1
0 4
1 12
0 4
1 11
1 13
0 2
0 3
1 18
1 15
1 14
0 2
1 19
0 4
0 3
0 3
1 20
1 21
1 16
0 4
1 23
0 3
1 24
0 4
0 4
0 3
1 17
1 3
0 1
1 28
1 1
0 3
1 26
1 4
1 29
1 22
1 27
0 1
0 2
1 31
1 30
0 3
0 3
0 1
1 34
0 2
1 32
0 2
0 1...

output:

QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv
0 2
1 4
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
1 2
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -1
0 -...

result:

ok both questions correct

Test #13:

score: 0
Runtime Error

input:

1
100
0 4
0 3
0 4
0 3
0 4
1 1
0 4
1 6
0 4
1 4
0 4
1 2
1 7
0 4
1 9
1 3
0 3
0 2
1 11
1 10
0 4
0 4
0 4
0 3
0 3
1 12
1 13
1 16
0 1
0 4
1 17
1 14
0 4
0 3
0 4
0 4
0 4
0 2
1 20
1 18
1 19
0 3
0 1
1 26
0 2
1 27
1 25
0 3
1 21
0 3
1 29
0 2
1 23
1 22
1 28
1 15
1 5
1 30
0 3
1 31
0 1
1 32
0 4
1 33
0 3
1 34
0 4
1 ...

output:


result:


Subtask #2:

score: 0
Runtime Error

Test #72:

score: 0
Runtime Error

input:

2
5000
0 2
0 1
0 3
1 3
0 4
1 4
0 3
1 5
0 1
0 2
1 7
1 1
0 2
0 3
0 3
1 9
1 8
1 10
0 1
1 11
0 2
0 4
1 12
0 4
0 4
0 3
1 14
1 15
0 1
1 13
0 3
0 3
1 2
0 4
0 3
1 21
0 1
1 22
1 20
1 6
1 16
1 19
0 3
1 23
0 4
0 1
0 1
1 25
1 18
1 17
0 4
0 4
0 1
0 4
0 2
1 31
1 28
1 27
0 4
1 32
1 29
1 26
0 4
1 33
0 2
0 3
1 35
1 ...

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #143:

score: 0
Runtime Error

input:

3
50000
0 2
0 1
0 1
1 1
0 4
1 2
0 1
1 4
0 3
1 6
0 4
1 7
0 1
0 4
1 3
1 8
0 3
0 1
0 2
0 3
1 10
1 13
0 3
0 2
0 1
0 2
1 14
1 17
0 4
0 1
1 18
1 15
1 16
0 4
0 1
1 20
1 21
1 19
1 11
1 5
0 1
0 4
1 23
1 9
0 1
1 24
0 3
0 1
1 25
1 26
0 3
0 3
1 27
1 28
0 1
1 29
0 4
0 4
0 1
1 31
1 30
0 1
1 33
1 32
0 4
0 4
1 34
1...

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #214:

score: 0
Runtime Error

input:

4
100000
0 3
0 3
0 3
0 4
0 2
1 4
0 2
0 2
0 3
0 2
0 1
0 2
0 3
0 1
1 7
1 5
1 12
0 2
0 2
1 1
1 10
0 2
1 14
0 3
1 17
0 2
1 8
0 1
0 1
0 4
1 20
1 11
1 6
0 1
1 9
1 21
1 19
1 18
1 22
1 3
1 15
1 16
0 1
0 2
0 2
1 23
0 2
0 2
1 26
0 4
0 4
1 29
1 25
0 4
0 1
0 3
0 2
1 31
1 32
1 24
0 4
1 34
1 27
0 4
0 2
0 1
1 35
0...

output:


result: