QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#667459 | #7686. The Phantom Menace | lamkappa | TL | 1100ms | 573764kb | C++20 | 10.5kb | 2024-10-22 23:13:59 | 2024-10-22 23:14:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#ifndef STL_PBDS
#define STL_PBDS
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#define _EXT_ENC_FILEBUF_H 1
#include <bits/extc++.h>
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;
// 平衡树
template<typename K_T,
typename Cmp = std::less<K_T>,
typename V_T = __gnu_pbds::null_type
>
using order_set = __gnu_pbds::tree<
K_T, // key_type
V_T, // value_type
Cmp, // comparator
__gnu_pbds::rb_tree_tag, // tag
__gnu_pbds::tree_order_statistics_node_update // policy
>;
template<typename K_T,
typename V_T = __gnu_pbds::null_type,
typename Cmp = std::less<K_T>
>
using order_map = order_set<K_T, Cmp, V_T>;
template<typename K_T, typename V_T, typename Cmp>
V_T& operator%(order_map<K_T,V_T,Cmp>&mp, const K_T&x){
return mp.lower_bound(x)->second;
}
/*
tag:
rb_tree_tag 红黑树
splay_tree_tag Slpay
ov_tree_tag 向量树
Itr ::point_iterator
std::pair<point_iterator, bool> insert(T) 插入
bool erase(T/Itr) 删除元素/迭代器
int order_of_key(T) 返回排名
Itr find_by_order(T) 排名对应元素
Itr lower_bound(T)/upper_bound(T) 二分查找
void join(order_set) 合并
void split(T,order_set) 保留<=,其余分离覆盖到order_set中
bool empty() 判空
size_t size() 大小
Itr begin()/end() 首尾迭代器
*/
/***************/
// 堆
template<typename T,
typename Cmp = std::greater<T>
>
using heap = __gnu_pbds::priority_queue<
T, // type
Cmp, // comparator
__gnu_pbds::pairing_heap_tag // tag
>;
/*
tag:
pairing_heap_tag 配对堆
thin_heap_tag 斐波那契堆
binomial_heap_tag 二项堆
binary_heap_tag 二叉堆
Itr ::point_iterator 可以指定为nullptr
usage:
Itr push(T) 入堆
void pop() 出堆
T top() 堆顶
void modify(Itr, T) 修改
void join(heap) 合并,清空heap
bool empty() 判空
size_t size() 大小
void clear() 清空
*/
/***************/
// 哈希表
const int RANDOM = std::chrono::high_resolution_clock::now().time_since_epoch().count();
template<typename K_T>
struct Chash{
int operator()(K_T x)const{return std::hash<K_T>{}(x)^RANDOM;}
};
template<typename K_T, typename V_T, typename Hash = Chash<K_T>>
using hash_table = __gnu_pbds::gp_hash_table<K_T, V_T, Hash>;
/*
tag:
cc_hash_table 拉链法
gp_hash_table 二次探测法
V_T& operaotr[](K_T) 映射
*/
// 字典树
using trie = __gnu_pbds::trie<
std::string, //
__gnu_pbds::null_type, //
__gnu_pbds::trie_string_access_traits<>, //
__gnu_pbds::pat_trie_tag, // tag
__gnu_pbds::trie_prefix_search_node_update // policy
>;
/*
Itr insert(string) 插入
void erase(string) 删除
void join(trie) 合并trie
std::pair<Itr, Itr> prefix_range(string) 前缀遍历[beign,end)
*/
#endif
#ifndef EULER_LOOP
#define EULER_LOOP
struct EulerLoop{
std::vector<hash_table<int, int>> adj;
EulerLoop(int n){
adj.assign(n, {});
}
void add_edge(int u, int v){
adj[u][v]++;
}
std::vector<int> find(int rt){
std::vector<int> ans;
// auto adj = this->adj;
auto dfs = [&](auto&&dfs, int u)->void{
while(!adj[u].empty()){
auto v = adj[u].begin()->first;
if(0 == --adj[u][v]){
adj[u].erase(v);
}
dfs(dfs, v);
}
ans.push_back(u);
};
dfs(dfs, rt);
reverse(ans.begin(), ans.end());
return ans;
}
bool empty()const{
bool fl = true;
for(const auto&x : adj){
fl &= x.empty();
}
return fl;
}
};
#endif
struct Hash{
static constexpr std::size_t C = 2;
using u64 = unsigned long long;
using hash = std::array<u64, C>;
hash val;
Hash() : val({0ull, 0ull}) {}
Hash(const std::initializer_list<u64>&list) {
std::copy(list.begin(), list.end(), val.begin());
}
bool operator==(const Hash&o)const{
return val == o.val;
}
Hash operator*(const Hash&o)const{
return {val[0] * o.val[0], val[1] * o.val[1]};
}
Hash operator+(u64 x)const{
return {val[0] + x, val[1] + x};
}
Hash operator+(const Hash&o)const{
return {val[0] + o.val[0], val[1] + o.val[1]};
}
Hash operator-(u64 x)const{
return {val[0] - x, val[1] - x};
}
Hash operator-(const Hash&o)const{
return {val[0] - o.val[0], val[1] - o.val[1]};
}
};
// const int RANDOM = std::chrono::high_resolution_clock::now().time_since_epoch().count();
namespace std {
template <>
struct hash<Hash> {
std::size_t operator()(Hash x)const{
return std::accumulate(x.val.begin(), x.val.end(), 0, std::bit_xor());
}
};
}
const Hash M = {51, 137};
constexpr int MAXM = 1e6+5;
std::array<Hash, MAXM> Mpow;
hash_table<Hash, int> A1, A2, B1, B2;
hash_table<Hash, int> mpA1, mpA2, mpB1, mpB2;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
Mpow[0] = {1, 1};
for(int i=1; i<MAXM; i++){
Mpow[i] = Mpow[i-1] * M;
}
int T; cin >> T;
while(T--){
int n, m; cin >> n >> m;
vector hA(n, vector<Hash>(m+1));
auto hB = hA;
for(int i=0; i<n; i++){
string s; cin >> s;
for(int j=1; j<=m; j++){
hA[i][j] = (hA[i][j-1]*M + (s[j-1] - 'a'));
}
}
for(int i=0; i<n; i++){
string s; cin >> s;
for(int j=1; j<=m; j++){
hB[i][j] = (hB[i][j-1]*M + (s[j-1] - 'a'));
}
}
for(int offset=0; offset<m; offset++){
A1.clear(); A2.clear(); B1.clear(); B2.clear();
for(int i=0; i<n; i++){
Hash a = hA[i][offset];
Hash b = hA[i][m] - hA[i][offset] * Mpow[m-offset];
A1[a]++; A2[b]++;
// B1[b]++; B2[a]++;
}
for(int i=0; i<n; i++){
Hash a = hB[i][m-offset];
Hash b = hB[i][m] - hB[i][m-offset] * Mpow[offset];
// A1[b]++; A2[a]++;
B1[a]++; B2[b]++;
}
bool fl = true;
for(auto[h, x] : A1) fl &= x == B2[h];
for(auto[h, x] : A2) fl &= x == B1[h];
// for(auto[h, x] : A1) fl &= (x % 2 == 0) && x == B2[h];
// for(auto[h, x] : A2) fl &= (x % 2 == 0) && x == B1[h];
// for(auto[h, x] : B1) fl &= (x % 2 == 0);
// for(auto[h, x] : B2) fl &= (x % 2 == 0);
if(fl){
mpA1.clear(), mpA2.clear(), mpB1.clear(), mpB2.clear();
int cnt = 0;
for(auto[h, _] : A1) mpA1[h] = cnt++;
auto cnt1 = cnt;
for(auto[h, _] : A2) mpA2[h] = cnt++;
auto cntAB = cnt;
for(auto[h, _] : B1) mpB1[h] = cnt++;
auto cnt2 = cnt;
for(auto[h, _] : B2) mpB2[h] = cnt++;
EulerLoop g(cnt);
hash_table<int, Hash> pos;
hash_table<Hash, vector<int>> segA, segB;
for(int i=0; i<n; i++){
Hash a = hA[i][offset];
Hash b = hA[i][m] - hA[i][offset] * Mpow[m-offset];
g.add_edge(mpB2[a], mpA1[a]);
g.add_edge(mpA1[a], mpA2[b]);
// g.add_edge(mpA2[b], mpB1[b]);
pos[mpA1[a]] = a;
pos[mpA2[b]] = b;
Hash ab = b + a * Mpow[m-offset];
segA[ab].push_back(i);
}
for(int i=0; i<n; i++){
Hash a = hB[i][m-offset];
Hash b = hB[i][m] - hB[i][m-offset] * Mpow[offset];
g.add_edge(mpA2[a], mpB1[a]);
g.add_edge(mpB1[a], mpB2[b]);
// g.add_edge(mpB2[b], mpA1[b]);
pos[mpB1[a]] = a;
pos[mpB2[b]] = b;
Hash ab = b + a * Mpow[m-offset];
segB[ab].push_back(i);
}
auto ans = g.find(0);
if(!g.empty()) continue;
vector<int> ans_A, ans_B;
for(int i=0; i<ans.size(); i++){
auto x = ans[i];
auto y = ans[(i+1)%ans.size()];
if(x < cntAB && y < cntAB){
if(x > y) swap(x, y);
Hash a = pos[x], b = pos[y];
Hash ab = b + a * Mpow[m-offset];
if(segA[ab].empty()) continue;
ans_A.push_back(segA[ab].back());
segA[ab].pop_back();
}else if(x >= cntAB && y >=cntAB){
if(x > y) swap(x, y);
Hash a = pos[x], b = pos[y];
Hash ab = b + a * Mpow[m-offset];
if(segB[ab].empty()) continue;
ans_B.push_back(segB[ab].back());
segB[ab].pop_back();
}
}
if(ans_A.size() != n || ans_B.size() != n) continue;
for(auto x : ans_A) cout << x+1 << ' '; cout << '\n';
for(auto x : ans_B) cout << x+1 << ' '; cout << '\n';
goto NEXT_CASE;
}
}
cout << "-1\n";
NEXT_CASE:;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 19220kb
input:
2 3 3 abc ghi def bcd efg hia 1 3 abc def
output:
2 1 3 3 1 2 -1
result:
ok 2 cases (2 test cases)
Test #2:
score: 0
Accepted
time: 930ms
memory: 19272kb
input:
1000000 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 ...
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 ...
result:
ok 1000000 cases (1000000 test cases)
Test #3:
score: 0
Accepted
time: 317ms
memory: 19488kb
input:
500000 1 2 dd ba 1 2 cd ba 1 2 bd ba 1 2 ad ba 1 2 dc ba 1 2 cc ba 1 2 bc ba 1 2 ac ba 1 2 db ba 1 2 cb ba 1 2 bb ba 1 2 ab ba 1 2 da ba 1 2 ca ba 1 2 ba ba 1 2 aa ba 1 2 dd aa 1 2 cd aa 1 2 bd aa 1 2 ad aa 1 2 dc aa 1 2 cc aa 1 2 bc aa 1 2 ac aa 1 2 db aa 1 2 cb aa 1 2 bb aa 1 2 ab aa 1 2 da aa 1 2...
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 ...
result:
ok 500000 cases (500000 test cases)
Test #4:
score: 0
Accepted
time: 338ms
memory: 19340kb
input:
500000 2 1 d d b a 2 1 c d b a 2 1 b d b a 2 1 a d b a 2 1 d c b a 2 1 c c b a 2 1 b c b a 2 1 a c b a 2 1 d b b a 2 1 c b b a 2 1 b b b a 2 1 a b b a 2 1 d a b a 2 1 c a b a 2 1 b a b a 2 1 a a b a 2 1 d d a a 2 1 c d a a 2 1 b d a a 2 1 a d a a 2 1 d c a a 2 1 c c a a 2 1 b c a a 2 1 a c a a 2 1 d...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 2 1 -1 -1 1 2 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 1 2 1 2 1 2 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 1 2 -1 -1 1 2 2 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 1 2 -1 -1 -1 -1 -1 1 2 2 1 -1 -1 -1 -1 -1 -1 -1 -1 -...
result:
ok 500000 cases (500000 test cases)
Test #5:
score: 0
Accepted
time: 244ms
memory: 19212kb
input:
333333 1 3 cbb bfa 1 3 bbb bfa 1 3 abb bfa 1 3 fab bfa 1 3 eab bfa 1 3 dab bfa 1 3 cab bfa 1 3 bab bfa 1 3 aab bfa 1 3 ffa bfa 1 3 efa bfa 1 3 dfa bfa 1 3 cfa bfa 1 3 bfa bfa 1 3 afa bfa 1 3 fea bfa 1 3 eea bfa 1 3 dea bfa 1 3 cea bfa 1 3 bea bfa 1 3 aea bfa 1 3 fda bfa 1 3 eda bfa 1 3 dda bfa 1 3 c...
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 ...
result:
ok 333333 cases (333333 test cases)
Test #6:
score: 0
Accepted
time: 235ms
memory: 19216kb
input:
333333 3 1 c b b b f a 3 1 b b b b f a 3 1 a b b b f a 3 1 f a b b f a 3 1 e a b b f a 3 1 d a b b f a 3 1 c a b b f a 3 1 b a b b f a 3 1 a a b b f a 3 1 f f a b f a 3 1 e f a b f a 3 1 d f a b f a 3 1 c f a b f a 3 1 b f a b f a 3 1 a f a b f a 3 1 f e a b f a 3 1 e e a b f a 3 1 d e a b f a 3 1 c...
output:
-1 -1 -1 2 3 1 3 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 3 1 2 3 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 3 1 1 3 2 -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 3 2 1 2 3 1 -1 -1 -1 -1 -...
result:
ok 333333 cases (333333 test cases)
Test #7:
score: 0
Accepted
time: 201ms
memory: 19208kb
input:
250000 1 4 hbca fhaa 1 4 gbca fhaa 1 4 fbca fhaa 1 4 ebca fhaa 1 4 dbca fhaa 1 4 cbca fhaa 1 4 bbca fhaa 1 4 abca fhaa 1 4 haca fhaa 1 4 gaca fhaa 1 4 faca fhaa 1 4 eaca fhaa 1 4 daca fhaa 1 4 caca fhaa 1 4 baca fhaa 1 4 aaca fhaa 1 4 hhba fhaa 1 4 ghba fhaa 1 4 fhba fhaa 1 4 ehba fhaa 1 4 dhba fhaa...
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 ...
result:
ok 250000 cases (250000 test cases)
Test #8:
score: 0
Accepted
time: 204ms
memory: 19212kb
input:
250000 4 1 h b c a f h a a 4 1 g b c a f h a a 4 1 f b c a f h a a 4 1 e b c a f h a a 4 1 d b c a f h a a 4 1 c b c a f h a a 4 1 b b c a f h a a 4 1 a b c a f h a a 4 1 h a c a f h a a 4 1 g a c a f h a a 4 1 f a c a f h a a 4 1 e a c a f h a a 4 1 d a c a f h a a 4 1 c a c a f h a a 4 1 b a c a f...
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 2 4 3 1 2 4 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 250000 cases (250000 test cases)
Test #9:
score: 0
Accepted
time: 173ms
memory: 19336kb
input:
200000 1 5 jjjjj baaaa 1 5 ijjjj baaaa 1 5 hjjjj baaaa 1 5 gjjjj baaaa 1 5 fjjjj baaaa 1 5 ejjjj baaaa 1 5 djjjj baaaa 1 5 cjjjj baaaa 1 5 bjjjj baaaa 1 5 ajjjj baaaa 1 5 jijjj baaaa 1 5 iijjj baaaa 1 5 hijjj baaaa 1 5 gijjj baaaa 1 5 fijjj baaaa 1 5 eijjj baaaa 1 5 dijjj baaaa 1 5 cijjj baaaa 1 5 b...
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 ...
result:
ok 200000 cases (200000 test cases)
Test #10:
score: 0
Accepted
time: 189ms
memory: 19252kb
input:
200000 5 1 j j j j j b a a a a 5 1 i j j j j b a a a a 5 1 h j j j j b a a a a 5 1 g j j j j b a a a a 5 1 f j j j j b a a a a 5 1 e j j j j b a a a a 5 1 d j j j j b a a a a 5 1 c j j j j b a a a a 5 1 b j j j j b a a a a 5 1 a j j j j b a a a a 5 1 j i j j j b a a a a 5 1 i i j j j b a a a a 5 1 h...
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 ...
result:
ok 200000 cases (200000 test cases)
Test #11:
score: 0
Accepted
time: 221ms
memory: 19440kb
input:
250000 2 2 hb ca fh aa 2 2 gb ca fh aa 2 2 fb ca fh aa 2 2 eb ca fh aa 2 2 db ca fh aa 2 2 cb ca fh aa 2 2 bb ca fh aa 2 2 ab ca fh aa 2 2 ha ca fh aa 2 2 ga ca fh aa 2 2 fa ca fh aa 2 2 ea ca fh aa 2 2 da ca fh aa 2 2 ca ca fh aa 2 2 ba ca fh aa 2 2 aa ca fh aa 2 2 hh ba fh aa 2 2 gh ba fh aa 2 2 f...
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 2 1 2 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
ok 250000 cases (250000 test cases)
Test #12:
score: 0
Accepted
time: 171ms
memory: 19268kb
input:
166666 2 3 jef aia aaa aaa 2 3 ief aia aaa aaa 2 3 hef aia aaa aaa 2 3 gef aia aaa aaa 2 3 fef aia aaa aaa 2 3 eef aia aaa aaa 2 3 def aia aaa aaa 2 3 cef aia aaa aaa 2 3 bef aia aaa aaa 2 3 aef aia aaa aaa 2 3 ldf aia aaa aaa 2 3 kdf aia aaa aaa 2 3 jdf aia aaa aaa 2 3 idf aia aaa aaa 2 3 hdf aia a...
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 ...
result:
ok 166666 cases (166666 test cases)
Test #13:
score: 0
Accepted
time: 166ms
memory: 19256kb
input:
166666 3 2 je fa ia aa aa aa 3 2 ie fa ia aa aa aa 3 2 he fa ia aa aa aa 3 2 ge fa ia aa aa aa 3 2 fe fa ia aa aa aa 3 2 ee fa ia aa aa aa 3 2 de fa ia aa aa aa 3 2 ce fa ia aa aa aa 3 2 be fa ia aa aa aa 3 2 ae fa ia aa aa aa 3 2 ld fa ia aa aa aa 3 2 kd fa ia aa aa aa 3 2 jd fa ia aa aa aa 3 2 id ...
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 ...
result:
ok 166666 cases (166666 test cases)
Test #14:
score: 0
Accepted
time: 140ms
memory: 19512kb
input:
125000 2 4 heio baaa aaaa aaaa 2 4 geio baaa aaaa aaaa 2 4 feio baaa aaaa aaaa 2 4 eeio baaa aaaa aaaa 2 4 deio baaa aaaa aaaa 2 4 ceio baaa aaaa aaaa 2 4 beio baaa aaaa aaaa 2 4 aeio baaa aaaa aaaa 2 4 pdio baaa aaaa aaaa 2 4 odio baaa aaaa aaaa 2 4 ndio baaa aaaa aaaa 2 4 mdio baaa aaaa aaaa 2 4 l...
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 ...
result:
ok 125000 cases (125000 test cases)
Test #15:
score: 0
Accepted
time: 143ms
memory: 19276kb
input:
125000 4 2 he io ba aa aa aa aa aa 4 2 ge io ba aa aa aa aa aa 4 2 fe io ba aa aa aa aa aa 4 2 ee io ba aa aa aa aa aa 4 2 de io ba aa aa aa aa aa 4 2 ce io ba aa aa aa aa aa 4 2 be io ba aa aa aa aa aa 4 2 ae io ba aa aa aa aa aa 4 2 pd io ba aa aa aa aa aa 4 2 od io ba aa aa aa aa aa 4 2 nd io ba ...
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 ...
result:
ok 125000 cases (125000 test cases)
Test #16:
score: 0
Accepted
time: 116ms
memory: 19444kb
input:
100000 2 5 ttjma aaaaa aaaaa aaaaa 2 5 stjma aaaaa aaaaa aaaaa 2 5 rtjma aaaaa aaaaa aaaaa 2 5 qtjma aaaaa aaaaa aaaaa 2 5 ptjma aaaaa aaaaa aaaaa 2 5 otjma aaaaa aaaaa aaaaa 2 5 ntjma aaaaa aaaaa aaaaa 2 5 mtjma aaaaa aaaaa aaaaa 2 5 ltjma aaaaa aaaaa aaaaa 2 5 ktjma aaaaa aaaaa aaaaa 2 5 jtjma aaa...
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 ...
result:
ok 100000 cases (100000 test cases)
Test #17:
score: 0
Accepted
time: 116ms
memory: 19312kb
input:
100000 5 2 tt jm aa aa aa aa aa aa aa aa 5 2 st jm aa aa aa aa aa aa aa aa 5 2 rt jm aa aa aa aa aa aa aa aa 5 2 qt jm aa aa aa aa aa aa aa aa 5 2 pt jm aa aa aa aa aa aa aa aa 5 2 ot jm aa aa aa aa aa aa aa aa 5 2 nt jm aa aa aa aa aa aa aa aa 5 2 mt jm aa aa aa aa aa aa aa aa 5 2 lt jm aa aa aa aa...
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 ...
result:
ok 100000 cases (100000 test cases)
Test #18:
score: 0
Accepted
time: 129ms
memory: 19440kb
input:
111111 3 3 oqa bba aaa aaa aaa aaa 3 3 nqa bba aaa aaa aaa aaa 3 3 mqa bba aaa aaa aaa aaa 3 3 lqa bba aaa aaa aaa aaa 3 3 kqa bba aaa aaa aaa aaa 3 3 jqa bba aaa aaa aaa aaa 3 3 iqa bba aaa aaa aaa aaa 3 3 hqa bba aaa aaa aaa aaa 3 3 gqa bba aaa aaa aaa aaa 3 3 fqa bba aaa aaa aaa aaa 3 3 eqa bba a...
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 ...
result:
ok 111111 cases (111111 test cases)
Test #19:
score: 0
Accepted
time: 105ms
memory: 19224kb
input:
83333 3 4 eqag aaaa aaaa aaaa aaaa aaaa 3 4 dqag aaaa aaaa aaaa aaaa aaaa 3 4 cqag aaaa aaaa aaaa aaaa aaaa 3 4 bqag aaaa aaaa aaaa aaaa aaaa 3 4 aqag aaaa aaaa aaaa aaaa aaaa 3 4 xpag aaaa aaaa aaaa aaaa aaaa 3 4 wpag aaaa aaaa aaaa aaaa aaaa 3 4 vpag aaaa aaaa aaaa aaaa aaaa 3 4 upag aaaa aaaa aaa...
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 ...
result:
ok 83333 cases (83333 test cases)
Test #20:
score: 0
Accepted
time: 103ms
memory: 19268kb
input:
83333 4 3 eqa gaa aaa aaa aaa aaa aaa aaa 4 3 dqa gaa aaa aaa aaa aaa aaa aaa 4 3 cqa gaa aaa aaa aaa aaa aaa aaa 4 3 bqa gaa aaa aaa aaa aaa aaa aaa 4 3 aqa gaa aaa aaa aaa aaa aaa aaa 4 3 xpa gaa aaa aaa aaa aaa aaa aaa 4 3 wpa gaa aaa aaa aaa aaa aaa aaa 4 3 vpa gaa aaa aaa aaa aaa aaa aaa 4 3 up...
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 ...
result:
ok 83333 cases (83333 test cases)
Test #21:
score: 0
Accepted
time: 93ms
memory: 19488kb
input:
66666 3 5 bquda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 aquda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 zpuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 ypuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 xpuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 wpuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 vpuda aaaaa aaaaa aaaaa aaaaa aaaaa 3 5 upuda aaaa...
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 ...
result:
ok 66666 cases (66666 test cases)
Test #22:
score: 0
Accepted
time: 92ms
memory: 19272kb
input:
66666 5 3 bqu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 aqu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 zpu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 ypu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 xpu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 wpu daa aaa aaa aaa aaa aaa aaa aaa aaa 5 3 vpu daa aaa aaa aaa aaa aa...
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 ...
result:
ok 66666 cases (66666 test cases)
Test #23:
score: 0
Accepted
time: 64ms
memory: 19316kb
input:
20833 6 8 gvebaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa 6 8 fvebaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa 6 8 evebaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaa...
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 ...
result:
ok 20833 cases (20833 test cases)
Test #24:
score: 0
Accepted
time: 59ms
memory: 19344kb
input:
15873 9 7 mmxaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa 9 7 lmxaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaaa aaaaaa...
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 ...
result:
ok 15873 cases (15873 test cases)
Test #25:
score: 0
Accepted
time: 53ms
memory: 19320kb
input:
10000 10 10 puoaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa 10 10 ouoaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaa...
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 ...
result:
ok 10000 cases (10000 test cases)
Test #26:
score: 0
Accepted
time: 624ms
memory: 19336kb
input:
250000 2 2 od ah ha do 2 2 il ng il ng 2 2 cf pf pf cf 2 2 wx ll wx ll 2 2 fg ge ge fg 2 2 dg mj dg mj 2 2 rj vw wr jv 2 2 er pv pv er 2 2 kc lb cl bk 2 2 dh zc hz cd 2 2 qv ce eq vc 2 2 lz um zu ml 2 2 hw xx hw xx 2 2 uk un ku nu 2 2 sg kx gs xk 2 2 ib xw ib xw 2 2 ar pd pd ar 2 2 ij si ii js 2 2 p...
output:
-1 1 2 1 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 2 1 2 1 1 2 1 2 2 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 2 1 2 1 2 1 1 2 1 2 -1 1 2 1 2 1 2 2 1 2 1 1 2 2 1 1 2 2 1 2 1 -1 2 1 1 2 1 2 2 1 1 2 2 1 1 2 1 2 1 2 1 2 2 1 2 1 -1 2 1 1 2 2 1 1 2 2 1 1 2 1 2 1 2 2 1 1 2...
result:
ok 250000 cases (250000 test cases)
Test #27:
score: 0
Accepted
time: 437ms
memory: 19176kb
input:
166666 2 3 aib avi aib avi 2 3 btw xjw xjw btw 2 3 dng ouv uvd ngo 2 3 ctq sve sve ctq 2 3 ott obm ott obm 2 3 aly tmx aly tmx 2 3 nhm zar arn hmz 2 3 knr qpa nrq pak 2 3 gsw fyn sng ywf 2 3 qcy rov qcy rov 2 3 nmj tyx tyx nmj 2 3 dbu pim pim dbu 2 3 afj zwf ffa wjz 2 3 vgo sky gyv kos 2 3 zru bog u...
output:
1 2 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 1 2 1 2 1 2 1 1 2 2 1 1 2 1 2 -1 1 2 1 2 1 2 2 1 2 1 1 2 -1 -1 -1 -1 2 1 2 1 -1 2 1 2 1 1 2 1 2 -1 1 2 2 1 2 1 1 2 1 2 2 1 1 2 1 2 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 -1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 2 -1 1 2...
result:
ok 166666 cases (166666 test cases)
Test #28:
score: 0
Accepted
time: 635ms
memory: 19500kb
input:
166666 3 2 yx pd tl dt xy lp 3 2 xb pc cr xb pc cr 3 2 bw bl so bw bl so 3 2 oq eu tx eu oq tx 3 2 tk ul ep le kt pu 3 2 ze en iq qe ei nz 3 2 zn vd nz nv zn dz 3 2 sn aa sl aa sn sl 3 2 cn lx jn cn lx jn 3 2 il td rf rf td il 3 2 up mr ex ru xe pm 3 2 pk vn pk pk vn pk 3 2 ke vj cp ke cp vj 3 2 aq ...
output:
-1 3 1 2 3 1 2 3 1 2 3 1 2 1 2 3 2 1 3 -1 1 3 2 2 1 3 -1 1 3 2 2 3 1 1 3 2 1 3 2 3 1 2 1 3 2 -1 3 1 2 3 1 2 1 3 2 1 2 3 1 2 3 1 3 2 1 3 2 1 3 2 2 3 1 2 3 1 3 2 1 1 2 3 1 3 2 3 2 1 1 2 3 2 3 1 1 2 3 3 2 1 1 3 2 2 3 1 3 2 1 2 1 3 3 2 1 3 1 2 1 2 3 3 2 1 1 2 3 2...
result:
ok 166666 cases (166666 test cases)
Test #29:
score: 0
Accepted
time: 1100ms
memory: 19332kb
input:
125000 8 1 b j r k f e h g f g h e r j b k 8 1 v d t w h h k o w v d h k h o t 8 1 s u k a a v i d a d v u s a k i 8 1 j l p m z o s f z o f l m p s j 8 1 h v s i j d a w d i j s w a h v 8 1 a h a e b w m l e l a m a h w b 8 1 q f y l s m d c c f d q y l s m 8 1 q c o k n a v w k q v n c a o w 8 1 f...
output:
8 1 3 2 5 4 7 6 2 7 5 6 1 8 3 4 1 3 2 6 5 4 8 7 2 8 3 6 4 1 7 5 1 3 2 6 5 4 8 7 5 7 4 3 6 1 2 8 8 1 3 2 5 4 7 6 3 8 6 4 1 5 7 2 8 1 3 2 5 4 7 6 5 7 4 8 3 2 6 1 3 1 4 2 6 5 8 7 5 3 1 6 7 8 2 4 8 1 3 2 5 4 7 6 1 4 5 2 7 6 3 8 8 1 3 2 5 4 7 6 8 2 7 5 4 1 3 6 8 1 3 2 5 4 7 6 7 2 6 8 1 4...
result:
ok 125000 cases (125000 test cases)
Test #30:
score: 0
Accepted
time: 233ms
memory: 19488kb
input:
100000 1 10 klhmhvkswy wykjhmhvks 1 10 uqieigoabd qieigoabdu 1 10 bunljqpvov vbunljqivo 1 10 ytkmhxtntc xtntcytkmh 1 10 lufmlhxbvz ufmlcxbvzl 1 10 cuemsefukn sefukncueq 1 10 oomyzzliuk zzliukoomy 1 10 piekrxtsag rxtsagpiek 1 10 pwhbveolnf nfpwhbveol 1 10 wsyjzqnbtj jzqnbojwsy 1 10 iqayiqecea aiqaytq...
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 ...
result:
ok 100000 cases (100000 test cases)
Test #31:
score: 0
Accepted
time: 347ms
memory: 19520kb
input:
28571 7 5 rpdbr kijbw qotha wvxmn frbey tdjed vqpoy havot bwfrb edrpd mnkij eyqqp oytdj brwvx 7 5 pecul iozuk kxkfg ivcha erold abatw otvoe otvoe kxkfg abatw ivcha pecul erold iozuk 7 5 qmwhz odnhu dkzle roeec xftep axzal kgusp ecdgu huxft epqmw lekkz alroe hzaxz spodn 7 5 aefno popfk shavv cvhdy na...
output:
-1 7 6 5 4 1 3 2 1 3 6 4 5 2 7 -1 2 1 7 4 6 3 5 3 5 4 6 1 7 2 -1 2 6 4 5 7 1 3 6 1 3 5 7 2 4 2 4 5 7 1 6 3 6 5 2 1 4 3 7 -1 6 5 7 1 2 4 3 1 3 5 7 2 6 4 -1 -1 2 4 5 1 3 6 7 5 4 6 3 2 7 1 6 4 2 1 7 3 5 6 2 4 7 1 5 3 -1 1 3 7 5 2 4 6 2 5 7 3 4 6 1 2 1 3 7 5 6 4 3 1 5 7 2 4 6 2 6 5 3 7...
result:
ok 28571 cases (28571 test cases)
Test #32:
score: 0
Accepted
time: 278ms
memory: 51128kb
input:
1 1000 1000 plxpgukngtaywjrcxufvdwswaozxzeeduaeqslxuzcevplzosuqsedbplkmzbpyogbndbzmyfeyqamtetcjmaosbaxcrmjanjeglavxlwksvvenehzgrovffaebdtpynzajedywisavqgjjtjnqktzltyfzbvrtsfmdkzsyougzyqcckjcjjtkewysagddaizqnnptunmfyqagnxrzjqpsoqzqptzvjnfilpbgmjbetcgnewclwqxmftpepudwufcmbqtpyxajfmabqyvlgqxzhgumauzxms...
output:
-1
result:
ok 1 cases (1 test case)
Test #33:
score: 0
Accepted
time: 460ms
memory: 311760kb
input:
1 500000 2 bh nk zd bw cc la zr if ts tq nz td rv th nw az pa qy cq uu rk sl du ll jn fw qm rw va ii as hw wo vt zi yt wx xd en ws we rw gk lp hh qp fj cu uu bp uq ge lb sa hg yx gm cu tr wj ws ei cv ct wn at ju mo bm ht ep ul jt yw wu ml sh vt kp ha ws qy pn nz aq wa my mf bq ff xo br uc pt ne ya i...
output:
497970 499294 498938 498885 496119 495154 492834 492787 489046 488901 486562 484540 484454 483556 483298 482695 482038 481871 480913 480124 479660 479078 477307 476753 476101 472843 472677 471881 470749 470058 469675 468692 467646 467384 466555 466171 464547 463089 463030 461685 461194 461098 460008...
result:
ok 1 cases (1 test case)
Test #34:
score: 0
Accepted
time: 614ms
memory: 571120kb
input:
1 1000000 1 f l m t y i g k v k g z f h n e v m b g a n i u v a k b e j x n m u a x a g t g a g v p q f g q i f t l t t w z l z n m v r v v t x w q h x h k n t m i y k e j b m u q x n u t v f n h z w g v r m x c a g x p p n w y x j t b d z n h f u u i y p c w b m d k p p m q j k o g g b r w c y d h ...
output:
1000000 999996 999967 999966 999951 999942 999926 999914 999913 999910 999878 999854 999818 999773 999745 999739 999736 999723 999710 999707 999677 999675 999652 999618 999563 999543 999518 999496 999492 999490 999489 999482 999453 999428 999396 999355 999336 999292 999177 999140 999129 999125 99912...
result:
ok 1 cases (1 test case)
Test #35:
score: 0
Accepted
time: 125ms
memory: 51752kb
input:
1 2 500000 yoskytdthibiosryionvxhjbnvwyrumjrmogzlngtxwkyxpketeperfdqboobxcccofgoxsjjffgdymvbhrnmcfiresutjbeadpbwuyxbirokynuisiezakhyivnbelkoexbfertmmmpjyerxyrnxvseyyipjqexidomwdzwqgqopwvnguawlvdyqgpsoxuliobzndxyfondeygqyxujboqcmqmwlptkpxflccjwfbzvwjkmddqxuenqirajuqplwjfyumjycekqzgavjrpanuxixmwlmnnvv...
output:
2 1 1 2
result:
ok 1 cases (1 test case)
Test #36:
score: 0
Accepted
time: 88ms
memory: 52184kb
input:
1 1 1000000 vvzoohphaekmooymvzpvxqaxbgyabgrgrdetsieivthqtvackeaapshmaybrwivlzjtjymeqmjqjoioeknzlajdqeptnywzscjthxqahapfnktonvxbyridjhokyielyfuzzgciiulnuetgfmdppmpywhoouwbbwyhlufupqwkhjubvkplfbzxiegngnewwfpupzypskuhtopvqzczthyaxpepvbkhvitkxgopxprykcrbjnuiideigftkhgzpykkoijuiquebxaaiwaabuxssgqgsofmiid...
output:
1 1
result:
ok 1 cases (1 test case)
Test #37:
score: 0
Accepted
time: 151ms
memory: 52700kb
input:
1 1000 1000 nnnaamfktzgakyenqodpbujtlowzoloijjqorpyvgfbujjivqhgrvcsuajhkfnxfrtrrhfanoutnxetnhowuknugksqgbtpyixedmyepfgyluqjvgadnsosbevsprmupvmymsmohjpimcbgkrybnnlrgqewddkotengibpfdpfqbehofyslubivwusaxzjnbbuczjponsogapfzqnshokuerpwuewcedjmtykebmibjanhyfhvuieexfxijacmpkqatvctadngmkuefrfqthukhywwqllwwy...
output:
658 826 245 953 982 30 358 217 883 721 410 118 311 844 959 927 36 496 527 866 561 355 127 49 896 878 454 390 303 940 377 300 951 474 975 564 226 391 422 675 150 977 598 295 451 948 400 549 580 270 571 929 667 638 276 681 16 500 833 498 592 272 872 670 264 469 886 538 418 576 154 838 491 456 315 420 ...
result:
ok 1 cases (1 test case)
Test #38:
score: 0
Accepted
time: 356ms
memory: 313776kb
input:
1 500000 2 lm hm wf rl ze qc ku dz is dg lc kw ys ho re gu pb on oe wc ya kx zh fg lb fn ys ci da ta mg nc qj tx tn zw gu na ee oa qm zz hx rs fl bz ik fm sq xr tf id lh bk sw qx lw aa bx cg ns vl bg im qp pc rh pa ns kf la pl am sz xs xq uc wf lz iq ok mh wi kj ui xl na fs vg wf qg rn th ju rp fs w...
output:
499879 498231 497551 497432 497229 495767 495415 494255 494111 493244 492705 492452 492448 491248 491213 490877 490746 490035 489442 489414 489320 488132 487918 486372 486058 484939 484884 484599 484270 482903 480197 480057 479956 478289 477686 477210 476763 476296 476285 475573 474944 473910 471545...
result:
ok 1 cases (1 test case)
Test #39:
score: 0
Accepted
time: 624ms
memory: 573764kb
input:
1 1000000 1 h v a h z d c r l b t l d s z h c n p d v t x a z k i q g d p s i a z l e f q t v r b a f v v c z c w u s e d p w c n y f d f j i x b a h m w g b z h d m y q y u d s g l m t p u x w m h c t y p u e l h s x m f t p d f z z k w h s y i h v j w w s v h y a r f y d j w e a h k p x l x a k f ...
output:
999966 999881 999874 999845 999825 999822 999809 999791 999786 999746 999741 999719 999705 999698 999689 999662 999657 999580 999571 999545 999514 999497 999485 999482 999311 999301 999244 999180 999149 999086 999038 999019 998996 998961 998953 998944 998910 998902 998894 998874 998858 998853 998799...
result:
ok 1 cases (1 test case)
Test #40:
score: 0
Accepted
time: 306ms
memory: 51740kb
input:
1 2 500000 csbazestpjffzjvrjztjidouhfewitwyhczwalacmlfmfpjozlnojeeltcyjkgbwpnzhzdeeublvjcgepkupvlqxhzkjfudcojhtxsrndyipgsuexhdjxodymiofmaxdkhsyallmorhqdrosgvzwvsgobotbwlwnqvohekjougktqmjaknocgtumjjvmtphfnoqrsrfgztpufvtnafmhmmcpxkrjyokgrlvaswhkkxfxguuakezavqkbkvnhjpycgvrsefranfttvrfnoaeempqhlsdzwtrvf...
output:
-1
result:
ok 1 cases (1 test case)
Test #41:
score: 0
Accepted
time: 77ms
memory: 52192kb
input:
1 1 1000000 zcgzehvspliuqlawrvemmxvlapmqsnpdieaqubpadgbsduckarfgikvmcphtdjtgczbfuivcjhpmwgaxoqvbmwldxvqwtcqizfyvxoahqcuyyvdgxzsohnkjblrwuyietchhqusxamzculyvhaqzoftboauhkdxnpxuxbljmftjtyrczfxxsbwkvzhehmwkhvbkjmnuypbjgibszsdtocihfzwuvdpvszccyroufgktzfytdkcrneuvelrcoufxvmxajvhlnikzfemppharjuwicizqodvrj...
output:
1 1
result:
ok 1 cases (1 test case)
Test #42:
score: 0
Accepted
time: 291ms
memory: 51064kb
input:
1 1000 1000 vkrkwbibcsuczrgypnuclsmvexjomqttgzmpebzbtmtltqyekywmlpmluwwmjjybbnztlxthcphhfayjjegghgyuippcrweyyzgjfnzemamafgtexvhxofarelxdoptwfohqrnjepcpxzkoepuluocahihxhqipydaiermnrbxjpkeundrirpdcalvbjyhhdazarjuwepzaiafcmbaxqlfqcnbzvlamfwgpqoutqvwhilaqswbqzvohiayenlifowexxzvuxrldswlfpjugwozxwzpxeqtkb...
output:
-1
result:
ok 1 cases (1 test case)
Test #43:
score: 0
Accepted
time: 446ms
memory: 312980kb
input:
1 500000 2 pa fn bi ka az wj sf db xb ad di ur he dq bv zf cw yw ha to hl al wi pq pq ao eh ua xo oi dw nz do dn oq sd bn nj fa mx vx ss pp dz jk us mv ko gk wa ju em bc tp qx cr rh ro qx vk bm ju ir kd ny gw sg js qt zi uf pg md du he qy ur ge dp ho hb ig zi dr wq ix my gz tf kb ab ye zf rx cy mq o...
output:
499937 499911 499825 499301 498274 497259 497231 496913 496907 496806 495824 495802 494313 494155 493990 493979 493189 490426 489691 489591 489565 488788 487749 486662 484375 482359 479830 477595 477490 477403 477251 477040 476901 476145 475237 474753 474620 474432 474065 473577 472545 472496 471172...
result:
ok 1 cases (1 test case)
Test #44:
score: 0
Accepted
time: 577ms
memory: 571732kb
input:
1 1000000 1 i b s i b r y g d n a s e b k h d f m c t a e u q d e s f p g t f u l v k z y s d d v m u e l c l v e q i o w f c k f f o y h b o r n h n j w d l z n p u n z t r w d e l g r u a v h t s k i y m q g a x z i p b w e m n i z g u g q c f c e h j e i t d r m g d h z w v y i l o u r m j l d p ...
output:
999992 999903 999839 999836 999777 999697 999675 999638 999632 999573 999559 999543 999523 999340 999295 999263 999213 999174 999075 999049 999016 999001 998996 998986 998962 998949 998917 998913 998898 998879 998845 998843 998819 998816 998811 998786 998774 998726 998721 998716 998655 998599 998475...
result:
ok 1 cases (1 test case)
Test #45:
score: 0
Accepted
time: 708ms
memory: 248680kb
input:
1 100000 10 ehlimdmwkt jlrfzdjvam jwtsqoiebv mlksfsakmd zamugzmeha nxepoofxsh idoigdreky ugarhoilzd oalhajmyfd vfnxfsoasz fymboaopqw rgyhcdtcxm nvgtvzxgqs uhwapwajcq udicenzrkr jgeaupojpv efrdqjgayp yvqwqkaipk jlsbzxdzeh btdjgvxcqd uqcoyaaohl szcxibrkvc yzyntbtiuo lbwkorixzq lfffvwuktb euhjmdnptr tb...
output:
22135 35686 54672 4104 466 64087 29891 58743 6664 57199 71255 95854 8012 10248 37883 36623 67418 72838 44019 40727 10456 40292 72052 15745 61662 7799 37312 59149 90905 5390 85779 63714 60855 59140 32807 41536 84973 82599 84769 18729 61392 60407 71948 13462 11639 47827 98817 53851 20872 25738 33524 8...
result:
ok 1 cases (1 test case)
Test #46:
score: 0
Accepted
time: 486ms
memory: 243080kb
input:
1 100000 10 mqpzaypqsg rybikrqyzx gxcfzgdglt sszegicsli oxzpnucwde ezkskhdmiu lqsgzsxckw jlglibuvpi ctqjnskviw yqhiaisjxf mpmgtaupwp swrhvwtxpg wcgchdtjyk hynexzwpxj veaomhaxnn bluwuxnmyj zeefjdwksv lgegdqxuyt ezkpautemn ykbpibnfsp ddbtafikzb cetuawmhwo epwldttkrv lytomstlzm wugxtmlmzf atathrowwp sv...
output:
17158 41690 25454 25359 40546 241 32887 29330 54235 5439 27320 67678 96465 18389 37103 85239 88984 8175 82174 89310 37361 51069 78685 66834 21782 90092 30838 65786 3834 88505 684 50197 18432 80648 60482 63798 49462 97683 86369 54710 8627 51435 8291 63053 49678 87421 42638 61317 76322 41197 34789 448...
result:
ok 1 cases (1 test case)
Test #47:
score: 0
Accepted
time: 316ms
memory: 162228kb
input:
1 200000 5 untrg qewwk zdlct ltaki tegsd pllgg jvwkk pkcru donwe elvdq crquy yqlbl yalff rwhfy xlsqg vzjww vjdni vevwr njecm onvvj ldfjq ypgae vuuvu jxgce weone hnklb hkkyw tuwyp kgcad octvg gfkei ovmql kxzta npvrv pxenv hklvf sfzso blanl jigxz uqcrk lbehm cxwbq ymdzw hmvpk wjdqq kpfls rktrp ogdhs f...
output:
-1
result:
ok 1 cases (1 test case)
Test #48:
score: -100
Time Limit Exceeded
input:
1 100000 10 fxhzgdmpvu rbapkxuwdz rcbtjgzlqz vuwjdihqwk brwenfhpot cazbgafcaa ylyhnyrgwt sixsqzjakz qdxsdrthuu zdrwkcqqdk xluoyqriep wpcqewlpfo ebcmamyzmt fanzqaxbew ikmsqafyun xczrzagmdn bbsvmsrtph sjtudpeyqj kdvxgfnozj pnbefumkkh xjahjflidu begdvasklf xcragpudlh pkugzyrpgn dtlznmvred supuawndia xa...