QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#242893#5541. Substring SorthieplpvipAC ✓353ms34816kbC++175.7kb2023-11-07 18:10:182023-11-07 18:10:18

Judging History

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

  • [2023-11-07 18:10:18]
  • 评测
  • 测评结果:AC
  • 用时:353ms
  • 内存:34816kb
  • [2023-11-07 18:10:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 5;

int n, q;

struct Node {
  Node *left = nullptr, *right = nullptr;
  int seg_id, node_id;
  char content;
};

struct SegmentTree {
  Node* root = nullptr;
  int id, cnt_nodes;
  string s;

  void build(Node* cur, int l, int r) {
    cur->seg_id = id;
    cur->node_id = ++cnt_nodes;
    if (l == r) {
      cur->content = s[l];
      return;
    }
    int mid = (l + r) / 2;
    cur->left = new Node();
    cur->right = new Node();
    build(cur->left, l, mid);
    build(cur->right, mid + 1, r);
  }

  void build() {
    s = "#" + s;
    cnt_nodes = 0;
    root = new Node();
    build(root, 1, n);
  }

  void build_output(Node* cur, int l, int r, string& res) {
    if (l == r) {
      res += cur->content;
      return;
    }
    int mid = (l + r) / 2;
    build_output(cur->left, l, mid, res);
    build_output(cur->right, mid + 1, r, res);
  }

  string output() {
    string res;
    build_output(root, 1, n, res);
    return res;
  }

  void split_nodes(Node* cur, int l, int r, int u, int v, vector<Node*>& nodes) {
    if (v < l || r < u) {
      return;
    }
    if (u <= l && r <= v) {
      nodes.push_back(cur);
      return;
    }
    int mid = (l + r) / 2;
    split_nodes(cur->left, l, mid, u, v, nodes);
    split_nodes(cur->right, mid + 1, r, u, v, nodes);
  }

  void split_nodes(int u, int v, vector<Node*>& nodes) {
    split_nodes(root, 1, n, u, v, nodes);
  }

  Node* merge_nodes(Node* cur, int l, int r, int u, int v, vector<Node*>& nodes) {
    if (v < l || r < u) {
      return cur;
    }
    if (u <= l && r <= v) {
      auto res = nodes.back();
      nodes.pop_back();
      return res;
    }
    int mid = (l + r) / 2;
    cur->left = merge_nodes(cur->left, l, mid, u, v, nodes);
    cur->right = merge_nodes(cur->right, mid + 1, r, u, v, nodes);
    return cur;
  }

  void merge_nodes(int u, int v, vector<Node*>& nodes) {
    root = merge_nodes(root, 1, n, u, v, nodes);
  }
} segtree[3];

bool is_equal[3][3][N << 2];

bool build_equal(Node* cur1, Node* cur2, int l, int r) {
  int node_id = cur1->node_id;
  assert(node_id == cur2->node_id);
  int st_id1 = cur1->seg_id;
  int st_id2 = cur2->seg_id;
  if (l == r) {
    bool match = segtree[st_id1].s[l] == segtree[st_id2].s[l];
    is_equal[st_id1][st_id2][node_id] = match;
    is_equal[st_id2][st_id1][node_id] = match;
    return match;
  }
  int mid = (l + r) / 2;
  bool match = build_equal(cur1->left, cur2->left, l, mid);
  match     &= build_equal(cur1->right, cur2->right, mid + 1, r);
  is_equal[st_id1][st_id2][node_id] = match;
  is_equal[st_id2][st_id1][node_id] = match;
  return match;
}

void build_equal(int st_id1, int st_id2) {
  build_equal(segtree[st_id1].root, segtree[st_id2].root, 1, n);
}

bool rebuild_equal(Node* cur1, Node* cur2, int l, int r, int u, int v) {
  int node_id = cur1->node_id;
  assert(node_id == cur2->node_id);
  int st_id1 = cur1->seg_id;
  int st_id2 = cur2->seg_id;
  if (v < l || r < u) {
    return is_equal[st_id1][st_id2][node_id];
  }
  if (u <= l && r <= v) {
    return is_equal[st_id1][st_id2][node_id];
  }
  int mid = (l + r) / 2;
  bool match = rebuild_equal(cur1->left, cur2->left, l, mid, u, v);
  match     &= rebuild_equal(cur1->right, cur2->right, mid + 1, r, u, v);
  is_equal[st_id1][st_id2][node_id] = match;
  is_equal[st_id2][st_id1][node_id] = match;
  return match;
}

void rebuild_equal(int st_id1, int st_id2, int u, int v) {
  rebuild_equal(segtree[st_id1].root, segtree[st_id2].root, 1, n, u, v);
}

int compare_node(Node* cur1, Node* cur2) {
  int node_id = cur1->node_id;
  assert(node_id == cur2->node_id);
  int st_id1 = cur1->seg_id;
  int st_id2 = cur2->seg_id;
  if (is_equal[st_id1][st_id2][node_id]) {
    return 0;
  }
  if (cur1->left == nullptr) {
    // l == r
    if (cur1->content < cur2->content) {
      return -1;
    } else if (cur1->content > cur2->content) {
      return 1;
    } else {
      return 0;
    }
  }
  int tmp = compare_node(cur1->left, cur2->left);
  if (tmp) return tmp;
  return compare_node(cur1->right, cur2->right);
}

void process_query(int u, int v) {
  vector<vector<Node*>> segs(3);
  for (int i = 0; i < 3; ++i) {
    segtree[i].split_nodes(u, v, segs[i]);
  }

  sort(segs.begin(), segs.end(), [&](const vector<Node*>& s1, const vector<Node*>& s2) {
    assert(s1.size() == s2.size());
    int k = s1.size();
    for (int i = 0; i < k; ++i) {
      auto cur1 = s1[i], cur2 = s2[i];
      int node_id = cur1->node_id;
      assert(node_id == cur2->node_id);
      int st_id1 = cur1->seg_id;
      int st_id2 = cur2->seg_id;
      if (!is_equal[st_id1][st_id2][node_id]) {
        return compare_node(cur1, cur2) == -1;
      }
    }
    return false;
  });

  for (int i = 0; i < 3; ++i) {
    reverse(segs[i].begin(), segs[i].end());
    segtree[i].merge_nodes(u, v, segs[i]);
  }

  rebuild_equal(0, 1, u, v);
  rebuild_equal(0, 2, u, v);
  rebuild_equal(1, 2, u, v);

//  for (int i = 0; i < 3; ++i) {
//    cout << segtree[i].output() << '\n';
//  }
//  cout << "-----------------\n";
}

int main() {
  if (fopen("input_e.txt", "r")) {
    freopen("input_e.txt", "r", stdin);
  }
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> n >> q;
  for (int i = 0; i < 3; ++i) {
    cin >> segtree[i].s;
    segtree[i].id = i;
    segtree[i].build();
  }
  build_equal(0, 1);
  build_equal(0, 2);
  build_equal(1, 2);

  while (q--) {
    int l, r;
    cin >> l >> r;
    process_query(l, r);
  }

  for (int i = 0; i < 3; ++i) {
    cout << segtree[i].output() << '\n';
  }

  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 2
icpca
siaja
karta
2 4
1 5

output:

iarta
kiaja
scpca

result:

ok 3 lines

Test #2:

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

input:

6 6
aabbcc
bcacab
cbcaba
1 1
2 2
3 3
4 4
5 5
6 6

output:

aaaaaa
bbbbbb
cccccc

result:

ok 3 lines

Test #3:

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

input:

3 1
aba
aab
aac
1 3

output:

aab
aac
aba

result:

ok 3 lines

Test #4:

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

input:

1 1
z
y
x
1 1

output:

x
y
z

result:

ok 3 lines

Test #5:

score: 0
Accepted
time: 305ms
memory: 34660kb

input:

100000 100000
llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll...

output:

llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll...

result:

ok 3 lines

Test #6:

score: 0
Accepted
time: 350ms
memory: 34616kb

input:

100000 100000
ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttottttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt...

output:

ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttotttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttqtttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttkttttttttttttttttttttttttttttttttttttttttttttttt...

result:

ok 3 lines

Test #7:

score: 0
Accepted
time: 333ms
memory: 34664kb

input:

100000 100000
aijpxjjjjcjwjjjjjmjajkjjjjjjoijjjjjjjjjeyjjwujvajjjjjjyjjjoejkhejdjoajjjzjjjjjkjjjjiqjjjjljjbjzjjjjjjepujjjjjejjjjjyjjjjjjjjjjjhjjjjjjjjjhjojejjjitjjjjjjjjjjujzjjrwjhjljjjjjjjjjjjjmjjjjjjjjjjzjjjjzijjjjjjjjjjjhjjjyjjjjjjjjrjjjjjjjjjjdbjjjvjjhjjcsjjrjjuljiejjjjjajkvjokrjhjkjjjjjjtljijjz...

output:

aicjbhjjjcjjjjjjjjjajkjjjjjjovfxjjjjjjjdjcjjjjjjjjnjjjejjjojjfhjzjkoajjdjjjjjjkjjjjijjjjjljjwjjjjjjjjjxjjjczjejjjjaykjjjdjjjjjjhjjjjvcjjjjjjjjjbjzykjjjdjjhtjujzjjzwjhjlocjjjjjjjjjjmnjjhjycjjjzjjjjjhjjjujjjjjjjcjjjyjjjjjjjcrdjjjjjjjjjdpfjrjjjjjjcfjjrjjujjjjjjjmhajkjjodnjjjkjjjjjjapjijjjjjejjljjtoayjj...

result:

ok 3 lines

Test #8:

score: 0
Accepted
time: 259ms
memory: 34428kb

input:

100000 100000
mvvvvvvvvvvvvvvvvvvvvvvvvevvvvvvvvvvvvvvvvvvvvvvvvdvvvvvvvvvvvvvvvvvvvvvvvvpvvvvvvvvvvvvvvvvvvvvvvvvdvvvvvvvvvvvvvvvvvvvvvvvvcvvvvvvvvvvvvvvvvvvvvvvvvkvvvvvvvvvvvvvvvvvvvvvvvvgvvvvvvvvvvvvvvvvvvvvvvvvtvvvvvvvvvvvvvvvvvvvvvvvvtvvvvvvvvvvvvvvvvvvvvvvvvbvvvvvvvvvvvvvvvvvvvvvvvvfvvvvvvvvvv...

output:

mvvvvvvvvvvvvvvvvvvvvvvvvevvvvvvvvvvvvvvvvvvvvvvvvdvvvvvvvvvvvvvvvvvvvvvvvvbvvvvvvvvvvvvvvvvvvvvvvvvdvvvvvvvvvvvvvvvvvvvvvvvvcvvvvvvvvvvvvvvvvvvvvvvvvevvvvvvvvvvvvvvvvvvvvvvvvavvvvvvvvvvvvvvvvvvvvvvvvtvvvvvvvvvvvvvvvvvvvvvvvvgvvvvvvvvvvvvvvvvvvvvvvvvbvvvvvvvvvvvvvvvvvvvvvvvvevvvvvvvvvvvvvvvvvvvvvvvv...

result:

ok 3 lines

Test #9:

score: 0
Accepted
time: 352ms
memory: 34620kb

input:

100000 100000
keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...

output:

keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...

result:

ok 3 lines

Test #10:

score: 0
Accepted
time: 320ms
memory: 34552kb

input:

100000 100000
wjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...

output:

mjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...

result:

ok 3 lines

Test #11:

score: 0
Accepted
time: 58ms
memory: 34464kb

input:

100000 100000
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

output:

cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

result:

ok 3 lines

Test #12:

score: 0
Accepted
time: 280ms
memory: 33312kb

input:

100000 100000
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq...

output:

qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq...

result:

ok 3 lines

Test #13:

score: 0
Accepted
time: 293ms
memory: 34580kb

input:

100000 100000
bccccbacaaaacaaaacabaacccabaabacacccbabcaacbbabbcbcaacbabccbccaaccbcaaabbccbaccbccbbaabcbbcbbabaabbaccabbcacbcabbbaabccbcbbbaccccbbabbacbabaabbbccccaabbbabbacabbcbaacbccababcbaccabccacbacbbaacbaaabaacabacbcccbbacbacbacaabbccabcaaaaabbbccccbaabacaaaacacbabcccaccbbaaaccbaacbbabcacbbaccab...

output:

aaaaaaaaaaaaaaaabaaaaaabaaababcaaacacccbabbabacbabbabaacbabacabbabbabbbbcaabaccacacabaacccaccbababbcccacabaccabaccbaaaccbaabbbbacaacaaaabcaabbacaacccccaabcacacccbccaabcacbcbbaabbcccbbcaccccbaacabccababcbbabaacaabcbaaabaaacabcbcacaabcaabbaaacbabbcbabbcbabcbbabccbbccbbabbcbcaaaaaaabcabacbbbbbbabbabaab...

result:

ok 3 lines

Test #14:

score: 0
Accepted
time: 252ms
memory: 33308kb

input:

100000 100000
bacbabbacabbbcbaccccabcbccbcbacaaabbcacaabaaacaacaccaccbabcbaccabbabccbcccacbccabbcacaacaaabcbbcccccacbabcaacccacabbccacacaccabcbcaaccbcbcbacacacbacaaaaacbcbcaccbacbcacccacacbbabcccaccbcbacbccbcabccabacccabcbbacaaacbbabbaaaaacaacabcaaabbacccbacacacbacbaabbccabaaabaccbacaaaaabcacacacacb...

output:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok 3 lines

Test #15:

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

input:

1 1
w
w
w
1 1

output:

w
w
w

result:

ok 3 lines

Test #16:

score: 0
Accepted
time: 353ms
memory: 34816kb

input:

100000 100000
hrwrlmxrhlyjibbyhspkrnnsvqowvahkzyurqhyjqpuousezjxotsbkdyuxmoffscrietmpyexgemtkkhfhergdxfjjthyplhysvakfbzoarnitovvdeetpvfcymorejruutwjboeyjvgefqpwupoddtyuqfynecsebasfsskfuwisafcwyjhxjueptownnuqugoqxuiylipyxyilgwhijfpqtkwhmkawbmmeicsxhhtvrblfslgzsxaaodwetqndawnqbtgxcvaobtxokmzagjewgismy...

output:

hrwrldxpmayviawdgrvvknqwjhonauhkzfpssodpmlfoveograuevoidyjilosvxaxesgmihnxgemkpvghrirgdxfjjthnprwfazykfhasfzjudzmrceuypugqsdbnejruudsddbenidxafqxwzpxgtfyvubpincsebapunvemvclcunnlinorgxplnsofypqxcsxavrdlkhhjzykgwsttwiiamhdfybebvddicsshhttbkgfkzglsclaodkjyqndljkbhghecbhrfarrkmzagjewgwjhqrgyxwdjqsolmex...

result:

ok 3 lines

Test #17:

score: 0
Accepted
time: 334ms
memory: 34472kb

input:

100000 100000
sxigpbnutawzekewadxbnkvbwocjfdfmtkqecqlfchesyygyqqzrobsjfkqgyruuotdgggxejzkvekezyjhqilvahkbrgtjccltijrpqpqnjyckhjjyrtkqgoaixczfkxdxzihslpqdazmjdypczbxlxzxrgjyxshyqdbknywltuuxteafyicqseszuaqlnvvsbknacmqdgagdygitmkldnihkpmjfdvhcotzhqeyqivmpwjjytbrdwldkfvhgilewiweauerretsupeudvtoqcrjaioie...

output:

bddgugahkamrekedaogbcdvargaurjfdtcocpygfcvtswbbjaqeoomzvfwegynknwtpgugygkzteeaejvvhanlmuhgqroekkfitzjtqoponedckhjfyftuogopioqzskxwuzndtrpddgmvhdyptcpblxtuqeafxaeyvotkvgjwtuhctisfgsvnlzlwjawqlvssljoncmfwgmjvjkizsklfvshcjmjpdapjsbzhwbivivjpeyxgturolprkovfgimeeivnzyerrgkfulrukwqlqcrbtisxeijbumidvltsfky...

result:

ok 3 lines

Test #18:

score: 0
Accepted
time: 318ms
memory: 34568kb

input:

100000 100000
jjrvgzoqdnqekkrmnknpoowdpicfhxoonddenrnjwblgcakwfmqhtajsigglkezubtonxtwpdeululjzzvavpkwpmzprxujafkhjduoacjpkqfmbibwixucewxuiwgkjrdctyjjslgordypqjcrxvpankaqjcdympwzpwnhghlphjejzrvrgoiubctqixxruerxfjailsqvbmgalwdwcyzwgfykmscvbmxlqwmbjkkczeguxxlilohovateiiyvjrvpvjqdsxdtjtqhuoymbjhakrmgpth...

output:

jjrvdlovdjiepsubnwxnhowdpicfhxumnbdjjdvqwblggcacmihttaxlxemtztptbtogktxmsewxigjsydrhpkwfysfsmeiqeehhftoaijpkqfdbibwixzcesnuiwgkcklpgnblmrgordypqnkdxvpacpmordthmpaakwnenjmahjdjzrvrdtigbsfigxrrdbnugjsvlsqvbkbilhuleydxrfykmjgvbfiufqpnjkkevhxfeklildtkbyeegnyvdcvpvjqcsxgtjyskuopsbyfybvblplnadcgpxmjuedget...

result:

ok 3 lines

Test #19:

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

input:

4 4
adsz
absd
basc
4 4
3 4
2 4
1 4

output:

aasz
absd
bdsc

result:

ok 3 lines

Test #20:

score: 0
Accepted
time: 116ms
memory: 13700kb

input:

27486 40833
svpwowlqqjlhxbzhjmuvnmokyvbicqajvyudwwzmuulnurdsqpdnytnckmgeutlfodaiqdpfqkyxrljplxscbzrqrefjdtipjioalqzycqfqezqpgkmmgqeicrridufyjrvacqvrczzwmnzbpltablhzdjhmdriwkxbfsoowgnnxcxocyhiarvdqsvhgekpoaevjadrohsthzlgtokpxoqfxyrllwzsdhtvkkrwgpiwzspsrnnyfqklqpmamhsrhhjqtlwdchcojpooaqzqilfxdjclzxgun...

output:

sqoqdcivdmldxbzdpwfgdhbuyqvncfamvcumwrebqulkwiagpuafuldxkzbeunldodavymppfcojppylqorynqjqxejomtmpegnleleinbzmpeqpggsmxceacmrssxggvrvacqpdtpzwmxzbpbrtsrfgujhextiwkyoqojokdqdscxcsyhuarmtqsejgeakncqijaylohyapuvhzbkbzmxfdbwllnasevdsukmkgspwzgdqugmbhakpupatrjsmhhrqaleucucojpozaqzqilgkysuczxpvbmrcxnlswpcad...

result:

ok 3 lines

Test #21:

score: 0
Accepted
time: 101ms
memory: 10348kb

input:

16247 43020
gkhfgkozymylzzeupoaavhhyzxqbsduyoepdpmbardxqmkvebrcgvwjggscpaqwrqwjnopuastbysarbiuawyvvdnhsarxixdmdhgjxzsqgcvputskskxtgdkhpricvnqcplzcizexdxicawfutylhvljytttbynhqeypdtvdpqctdxkvmbityeqpdnjrvwxeecjujokdwaxulhospusmzjdqwqpymkfqxsnqngvakgwhignjbrcgjgxalgfbojugfjiarkuttvmgjtuxiknbriuovnlmizp...

output:

gedfgkopahletkwuzaaavhirxouerdeyobpjpmbafdxwmzwpbstzywrzwwcbbqdchbnlopcvgtbyoanpioagypvfnmxuzvuxcmhwvjxzixtyvpuuskmcxtgfkbzrsdawxmpszuilfgdlegpwfunyltdtgytvtbmshmlypptvnpqwkowdvmsblybqpjbsrbfcewcrujihtweoalktbpqqmdkdbwjpybyfdxsiqngeatcwbwvunbrmijoaowthbokwfyjgacruxrjmgiuuxikhbrzuonzwqinpninimokcgsfh...

result:

ok 3 lines

Test #22:

score: 0
Accepted
time: 134ms
memory: 16092kb

input:

41563 43585
hyfoxmsexwutmmxvfzsuxexyvyngsaswzhgravymmponvzxzhymteflmhqmyxkumfzhmkxfhumpgrmuwcuvduxwwxxrztdnodedvbipjibrnwjscdkwwwqvuybocqgtjmzbjcocwwlnysjlyllrwxpaybuhazpbpgqbjvluqaacjktkylcgwucofcptygawolpiuqudfrulysmxaqzjbufatcjuqkhhqouxobitkimnabxgiaehhaciseccthislpjbiihejsndcgcyxezohgtlddkecmeft...

output:

fncicqmexwhcmbkwflsusvpyvynucasynhgrkvyerchnnljzhymyisbwxbxyxheqpgvfodkjlmkbrmugquvduxwfxxgztfzidbgjzvktibrniubjvrxwjqvuyufcpgtwijbjcocwwsjxajlyujuixpvunumjzuobijaciflaaackktoglcgeehowmptygautnpiumnhiktlkcpxhczerjmaezeklieeovqmtnemayjyyjvqiaehiamisexrxwxgljmboihhisnzmgcyxsqohteobwgecmesnwstxjajplegs...

result:

ok 3 lines

Test #23:

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

input:

33194 36811
migurpyumyjthmmhctxrweckuebrkhonoirgbipbgeftnawzqfyijdwyavtzysxhvcusfknonbhlcbjeoywfbaoixsgnyvfrpfvbikheiukvnftmqiqxwopiozonvqqsihqadomsishfdwcuwfafwawtsxlofucmuwhzcsvvsidgehgyeybrudyczejjcoetknjfjnkyjraoxfsimmzjfdwrklmsiggknrrdvntfddpddwgsuchudcgaalbwgmzybievdelradiklprolmvvertzxkctqshw...

output:

mifhjbkcmojehvmgcaiunpckqenanhoxhivkbxpzgjgzaqplqyfklfgyjjnzynxdvlaenkjoobhlybjvoywysyhufognxkenpqturublbnkvfntybiggzoalozmnvnxsihqtaembmshfrwcfdfafhaatbxllquruutyarsxisxdgpufyeggrtrvxzezdtoetxayzchkimraosflimytvkdoruhpdwbhhvcrsevtfddpduwpquzhuucgxademgmsufifvdekrblikloxolmvbczakxohtwrywgpcjknzukzxu...

result:

ok 3 lines

Test #24:

score: 0
Accepted
time: 152ms
memory: 18368kb

input:

49558 49843
cbofhipshjqyaeigtwhfxdfslpvnrepwotsujyvzyxzajiwcmmmzxrxvsvssfhhtqadzlpcchjthwrcxzdpuwezrryakbbvpbijomoxysorgbkytclureigezreytvjsvpapnjpqpzhwtwwsnclpazkmybluftxielnhdukhhvbdxxfvytyuwufhxuxbdqvblzfyessweunyquobdhmgdqzvmzumavzvizulvgcrrvjjugvcatuuueyudztkzwuutazmigguhnqdwiptfuurvmpakuqhgrdt...

output:

abzfefbbmjqheeigtwhatdfnlphwebpworhejyvrzmhajiwcmmmzjpxrjolvfhhfqbsoudweyhhvmiiysjtjwvbrgyaotbonztgoshngqurgfkyyfeucilerzreyddjsvcnxzzymomhxzyhynrabrfkdwclffqaielnhdpaleaxarkovytyqwufhqnnisbpekzfyeexeeunemarfdhmgfyddmsdbavzvizbwtizrruijaqbzatuuuhwxvstlwvehbazmigguhdzdwxqaslurvyjakuqhhkctgcilulziaosy...

result:

ok 3 lines

Test #25:

score: 0
Accepted
time: 143ms
memory: 19456kb

input:

47097 47879
lgfihdebrdscubyblbaxnnshsgevdmpdfzehqxyipfosbddjbwwvosusbcftpriisyvghbgudzwjxczdrqvcewnyeialotookodvgxsfiwklkjymdmltszrwzwiocgfiuomhhzwgjpyiawkztluepsjevloknxgesgwqqonekopnfkuxskwrafenrjvujdzajdfpfnwjwzmtffacgirennllocsedqfhwdoabwevtrlvnerogrpriikiiscdggavxyiczvsizmekwutvvnkxqbzxquqoasxh...

output:

lgfcedebrcewubfuqbawwvyhsznvshxdzletgpxnyissbpvzelehpqisbsfuxrbayevohxwrdnmesczdrrrceqqhsidlrwkokufoghsfhwnlkkyxdmlxttjwzwipbgfiunbhbrwzqwyicsxmbcutpbcyzxowuxgeepxqggnsuoiysgorswufxeckrkcujwzgselgvmgjswmsvxacglewsiqyjvcyrqsrnxldowspgtlzgtksrtrobicltfcehgavxuicavrycmukwuttaxarnmznklqomditelprlwcrnuzw...

result:

ok 3 lines