QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#237816 | #7686. The Phantom Menace | ucup-team896# | RE | 137ms | 153476kb | C++23 | 10.2kb | 2023-11-04 15:04:40 | 2023-11-04 15:04:41 |
Judging History
你现在查看的是最新测评结果
- [2024-10-08 14:11:03]
- hack成功,自动添加数据
- (/hack/941)
- [2024-10-08 10:05:28]
- hack成功,自动添加数据
- (/hack/940)
- [2024-10-07 19:51:15]
- hack成功,自动添加数据
- (/hack/938)
- [2024-10-07 19:28:01]
- hack成功,自动添加数据
- (/hack/937)
- [2024-10-07 17:16:32]
- hack成功,自动添加数据
- (/hack/936)
- [2024-10-07 16:53:09]
- hack成功,自动添加数据
- (/hack/935)
- [2024-10-07 16:22:17]
- hack成功,自动添加数据
- (/hack/934)
- [2023-11-09 15:33:42]
- hack成功,自动添加数据
- (//qoj.ac/hack/445)
- [2023-11-04 15:04:40]
- 提交
answer
/*
* @Author: cmk666
* @Created time: 2023-11-04 13:47:26
* @Last Modified time: 2023-11-04 15:04:21
*/
#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
#ifdef LOCAL
#include"debug.h"
#else
#define D(...) ((void)0)
#endif
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
namespace FastIO
{
// ------------------------------
// #define IN_HAS_NEG
// #define OUT_HAS_NEG
// #define CHK_EOF
// #define DISABLE_MMAP
// ------------------------------
#if __cplusplus < 201400
#error Please use C++14 or higher.
#endif
#if __cplusplus > 201700
#define INLINE_V inline
#else
#define INLINE_V
#endif
#if ( defined(LOCAL) || defined(_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifndef DISABLE_MMAP
#include<sys/mman.h>
#endif
#ifdef LOCAL
inline char gc() { return getchar(); }
inline void pc(char c) { putchar(c); }
#else
#ifdef DISABLE_MMAP
INLINE_V constexpr int _READ_SIZE = 1 << 18;
INLINE_V static char _read_buffer[_READ_SIZE], *_read_ptr = nullptr, *_read_ptr_end = nullptr;
inline char gc()
{
if ( __builtin_expect(_read_ptr == _read_ptr_end, false) )
{
_read_ptr = _read_buffer;
_read_ptr_end = _read_buffer + fread(_read_buffer, 1, _READ_SIZE, stdin);
#ifdef CHK_EOF
if ( __builtin_expect(_read_ptr == _read_ptr_end, false) ) return EOF;
#endif
}
return *_read_ptr++;
}
#else
INLINE_V static const char *_read_ptr = (const char *)mmap(nullptr, INT_MAX, 1, 2, 0, 0);
inline char gc() { return *_read_ptr++; }
#endif
INLINE_V constexpr int _WRITE_SIZE = 1 << 18;
INLINE_V static char _write_buffer[_WRITE_SIZE], *_write_ptr = _write_buffer;
inline void pc(char c)
{
*_write_ptr++ = c;
if ( __builtin_expect(_write_buffer + _WRITE_SIZE == _write_ptr, false) )
{
fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout);
_write_ptr = _write_buffer;
}
}
INLINE_V struct _auto_flush
{
inline ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); }
} _auto_flush;
#endif
#ifdef CHK_EOF
inline constexpr bool _isdigit(char c) { return ( c & 16 ) && c != EOF; }
inline constexpr bool _isgraph(char c) { return c > 32 && c != EOF; }
#else
inline constexpr bool _isdigit(char c) { return c & 16; }
inline constexpr bool _isgraph(char c) { return c > 32; }
#endif
template < class T >
INLINE_V constexpr bool _is_integer = numeric_limits < T >::is_integer;
template < class T >
INLINE_V constexpr bool _is_signed = numeric_limits < T >::is_signed;
template < class T >
INLINE_V constexpr bool _is_unsigned = _is_integer < T > && !_is_signed < T >;
template <> INLINE_V constexpr bool _is_integer < __int128 > = true;
template <> INLINE_V constexpr bool _is_integer < __uint128_t > = true;
template <> INLINE_V constexpr bool _is_signed < __int128 > = true;
template <> INLINE_V constexpr bool _is_unsigned < __uint128_t > = true;
#undef INLINE_V
inline void read(char &c) { do c = gc(); while ( !_isgraph(c) ); }
inline void read_cstr(char *s)
{
char c = gc(); while ( !_isgraph(c) ) c = gc();
while ( _isgraph(c) ) *s++ = c, c = gc();
*s = 0;
}
inline void read(string &s)
{
char c = gc(); s.clear(); while ( !_isgraph(c) ) c = gc();
while ( _isgraph(c) ) s.push_back(c), c = gc();
}
#ifdef IN_HAS_NEG
template < class T, enable_if_t < _is_signed < T >, int > = 0 >
inline void read(T &x)
{
char c = gc(); bool f = true; x = 0;
while ( !_isdigit(c) ) { if ( c == 45 ) f = false; c = gc(); }
if ( f ) while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
else while ( _isdigit(c) ) x = x * 10 - ( c & 15 ), c = gc();
}
template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
inline void read(T &x)
{
char c = gc(); while ( !_isdigit(c) ) c = gc();
x = 0; while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
}
inline void write(char c) { pc(c); }
inline void write_cstr(const char *s) { while ( *s ) pc(*s++); }
inline void write(const string &s) { for ( char c : s ) pc(c); }
#ifdef OUT_HAS_NEG
template < class T, enable_if_t < _is_signed < T >, int > = 0 >
inline void write(T x)
{
char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
if ( x >= 0 ) do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
else { pc(45); do buffer[digits++] = -( x % 10 ) | 48, x /= 10; while ( x ); }
while ( digits ) pc(buffer[--digits]);
}
template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
inline void write(T x)
{
char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
while ( digits ) pc(buffer[--digits]);
}
template < int N > struct _tuple_io_helper
{
template < class ...T >
static inline void _read(tuple < T... > &x)
{ _tuple_io_helper < N - 1 >::_read(x), read(get < N - 1 > (x)); }
template < class ...T >
static inline void _write(const tuple < T... > &x)
{ _tuple_io_helper < N - 1 >::_write(x), pc(32), write(get < N - 1 > (x)); }
};
template <> struct _tuple_io_helper < 1 >
{
template < class ...T >
static inline void _read(tuple < T... > &x) { read(get < 0 > (x)); }
template < class ...T >
static inline void _write(const tuple < T... > &x) { write(get < 0 > (x)); }
};
template < class ...T >
inline void read(tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_read(x); }
template < class ...T >
inline void write(const tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_write(x); }
template < class T1, class T2 >
inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
template < class T1, class T2 >
inline void write(const pair < T1, T2 > &x) { write(x.first), pc(32), write(x.second); }
template < class T1, class ...T2 >
inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
template < class ...T >
inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
template < class T1, class ...T2 >
inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
template < class ...T >
inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
template < class T >
inline void print(const T &x) { write(x); }
inline void print_cstr(const char *x) { write_cstr(x); }
template < class T1, class ...T2 >
inline void print(const T1 &x, const T2 &...y) { print(x), pc(32), print(y...); }
template < class ...T >
inline void print_cstr(const char *x, const T *...y) { print_cstr(x), pc(32), print_cstr(y...); }
inline void println() { pc(10); }
inline void println_cstr() { pc(10); }
template < class ...T >
inline void println(const T &...x) { print(x...), pc(10); }
template < class ...T >
inline void println_cstr(const T *...x) { print_cstr(x...), pc(10); }
}
using namespace FastIO;
constexpr ll B = 233, P = 1145141919810000037;
ll pw[1000009];
inline ll mul(ll x, ll y, ll p)
{
ll z = x * y - (ll)( 1.l * x * y / p ) * p;
z >= p && ( z -= p ), z < 0 && ( z += p );
return z;
}
inline void init(int x) { *pw = 1; For(i, 1, x) pw[i] = mul(pw[i - 1], B, P); }
inline void calc_hash(auto &h, int n, char *s)
{
h.resize(n + 1), h[0] = 0;
For(i, 1, n) { h[i] = mul(h[i - 1], B, P) + s[i] - 'a' + 1; if ( h[i] >= P ) h[i] -= P; }
}
inline ll qry(const auto &h, int l, int r)
{
ll z = h[r] - mul(h[l - 1], pw[r - l + 1], P);
return z >= 0 ? z : z + P;
}
char s[1000009]; bool ok; vector < ll > hs[1000009], ht[1000009];
vector < int > res, g[4000009]; ll num[4000009];
int n, m, ids[1000009], idt[1000009], ls, lt, len, degi[4000009], dego[4000009];
struct hasher { inline int operator()(const auto &x)const { return x.first ^ x.second; } };
unordered_map < pair < int, int >, vector < int >, hasher > e[2];
inline void dfs(int u)
{
for ( int v ; g[u].size() ; ) v = g[u].back(), g[u].pop_back(), dfs(v);
res.push_back(u);
}
inline void work()
{
read(n, m), init(m);
For(i, 1, n) read_cstr(s + 1), calc_hash(hs[i], m, s);
For(i, 1, n) read_cstr(s + 1), calc_hash(ht[i], m, s);
iota(ids + 1, ids + n + 1, 1), iota(idt + 1, idt + n + 1, 1),
sort(ids + 1, ids + n + 1, [&](int x, int y) { return hs[x][m] < hs[y][m]; }),
sort(idt + 1, idt + n + 1, [&](int x, int y) { return ht[x][m] < ht[y][m]; });
ok = true;
For(i, 1, n) if ( hs[ids[i]][m] != ht[idt[i]][m] ) { ok = false; break; }
if ( ok )
{
For(i, 1, n) write(ids[i], i == n ? '\n' : ' ');
For(i, 1, n) write(idt[i], i == n ? '\n' : ' ');
return;
}
For(l, 1, m - 1)
{
len = 0;
For(i, 1, n) num[++len] = qry(hs[i], 1, l), num[++len] = qry(hs[i], l + 1, m);
For(i, 1, n) num[++len] = qry(ht[i], 1, m - l), num[++len] = qry(ht[i], m - l + 1, m);
sort(num + 1, num + len + 1), len = unique(num + 1, num + len + 1) - num - 1;
const auto id = [&](ll x) -> int { return lower_bound(num + 1, num + len + 1, x) - num; };
For(i, 1, len) g[i].clear(), degi[i] = dego[i] = 0;
e[0].clear(), e[1].clear();
const auto addedge = [&](int u, int v, int w, int f) {
g[u].push_back(v), e[f][pair(u, v)].push_back(w), dego[u]++, degi[v]++;
};
For(i, 1, n) addedge(id(qry(hs[i], 1, l)), id(qry(hs[i], l + 1, m)), i, 0);
For(i, 1, n) addedge(id(qry(ht[i], 1, m - l)), id(qry(ht[i], m - l + 1, m)), i, 1);
ok = true;
For(i, 1, len) if ( degi[i] != dego[i] ) { ok = false; break; }
if ( !ok ) continue;
res.clear(), dfs(id(qry(hs[1], 1, l)));
if ( (int)res.size() != n + n + 1 ) continue;
ls = lt = 0;
Fol(i, n + n, 1)
{
auto p = pair(res[i], res[i - 1]);
if ( i & 1 ) assert(e[1][p].size()), idt[++lt] = e[1][p].back(), e[1][p].pop_back();
else assert(e[0][p].size()), ids[++ls] = e[0][p].back(), e[0][p].pop_back();
}
For(i, 1, n) write(ids[i], i == n ? '\n' : ' ');
For(i, 1, n) write(idt[i], i == n ? '\n' : ' ');
return;
}
println("-1"s);
}
int main() { int t; read(t); For(tt, 1, t) work(); return 0; }
// 想上GM捏 想上GM捏 想上GM捏 想上GM捏 想上GM捏
// 伊娜可爱捏 伊娜贴贴捏
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 144656kb
input:
2 3 3 abc ghi def bcd efg hia 1 3 abc def
output:
1 3 2 1 2 3 -1
result:
ok 2 cases (2 test cases)
Test #2:
score: 0
Accepted
time: 48ms
memory: 153476kb
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 1 1 1 1 -1 -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: 104ms
memory: 152144kb
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 -1 1 1 -1 -1 -1 -1...
result:
ok 500000 cases (500000 test cases)
Test #4:
score: 0
Accepted
time: 32ms
memory: 153308kb
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 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 2 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 1 2 -1 -1 2 1 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 1 2 -1 -1 -1 -1 -1 2 1 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 1 2 -1 ...
result:
ok 500000 cases (500000 test cases)
Test #5:
score: 0
Accepted
time: 122ms
memory: 150352kb
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 -1 -1 ...
result:
ok 333333 cases (333333 test cases)
Test #6:
score: 0
Accepted
time: 39ms
memory: 150032kb
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 3 1 2 3 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 2 1 3 1 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 1 2 3 1 3 2 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 333333 cases (333333 test cases)
Test #7:
score: 0
Accepted
time: 137ms
memory: 148608kb
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 -1...
result:
ok 250000 cases (250000 test cases)
Test #8:
score: 0
Accepted
time: 31ms
memory: 150092kb
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 3 4 1 2 3 4 1 2 -1 -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: 132ms
memory: 148476kb
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: 32ms
memory: 152100kb
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: -100
Runtime Error
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...