QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#824725#9769. Rolling Stonesucup-team6225#AC ✓9ms12532kbC++143.6kb2024-12-21 15:24:572024-12-21 15:25:02

Judging History

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

  • [2024-12-21 15:25:02]
  • 评测
  • 测评结果:AC
  • 用时:9ms
  • 内存:12532kb
  • [2024-12-21 15:24:57]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;

const int N = 210, M = N * N * 6, SZ = (1 << 18) + 5;
static char buf[SZ], *bgn = buf, *til = buf;
char getc() {
    if(bgn == til)  bgn = buf, til = buf + fread(buf, 1, SZ, stdin);
    return bgn == til ? EOF : *bgn++;
}
template<typename T>
void read(T &x) {
    char ch = getc();  T fh = 0;   x = 0;
    while(ch < '0' || ch > '9')    fh |= (ch == '-'), ch = getc();
    while(ch >= '0' && ch <= '9')   x = x * 10 + ch - '0', ch = getc();
    x = fh ? -x : x;
}
template<typename Type, typename... argc>
void read(Type &x, argc &...args)   {read(x), read(args...);}
template<typename T>
void print(T x) {
    if(x < 0)  putchar('-'), x = -x;
    if(x / 10)  print(x / 10);
    putchar(x % 10 + '0');
}
int n, a[N][N], ans = M, edx, edy, num[5][5], dis[M];
vector<int> edge[M];
int check(int x, int y) {
    return x > 0 && y > 0 && x <= n && y < x + x;
}
int id(int x, int y, int pos) {
    return ((x - 1) * (x - 1) + y - 1) * 6 + pos + 1;
}
void bfs() {
    memset(dis, 0x3f, sizeof(dis));
    queue<int> q;   dis[id(1, 1, 2)] = 0, q.push(id(1, 1, 2));
    while(!q.empty()) {
        int x = q.front();  q.pop();
        // cerr << x << " " << dis[x] << "\n";
        for(int y : edge[x])
            if(dis[y] > dis[x] + 1) dis[y] = dis[x] + 1, q.push(y);
    }
}
int main() {
    #ifdef Kelly
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    read(n);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j < i + i; ++j)  read(a[i][j]);
    read(edx, edy);
    for(int i = 1; i <= 4; ++i) {
        int nw = 0;
        for(int j = 1; j <= 4; ++j) if(i != j)  num[i][j] = nw++;
    }
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j < i + i; ++j) {
            int ps = (j & 1) ? 1 : -1, fl = a[i][j];
            for(int k = 1; k <= 4; ++k) {
                if(k == fl)    continue;
                vector<int> tmp;    
                for(int v = 1; v <= 4; ++v) if(v != a[i][j] && v != k)  tmp.pb(v);
                for(int op : {0, 1}) {
                    int l = tmp[0], r = tmp[1];
                    if(op)  swap(l, r);
                    if(check(i + ps, j + ps) && a[i + ps][j + ps] == k) {
                        edge[id(i, j, num[fl][k] * 2 + op)].pb(id(i + ps, j + ps, num[a[i + ps][j + ps]][fl] * 2 + op));
                        // cerr << i << " " << j << " " << num[fl][k] * 2 + op << " " << id(i, j, num[fl][k] * 2 + op) << " 1\n"; 
                    }
                    if(check(i, j - 1) && a[i][j - 1] == l) {
                        edge[id(i, j, num[fl][k] * 2 + op)].pb(id(i, j - 1, num[a[i][j - 1]][r] * 2 + (k > fl)));
                        // cerr << i << " " << j << " " << num[fl][k] * 2 + op << " " << id(i, j, num[fl][k] * 2 + op) << " 2\n"; 
                    }
                    if(check(i, j + 1) && a[i][j + 1] == r) {
                        edge[id(i, j, num[fl][k] * 2 + op)].pb(id(i, j + 1, num[a[i][j + 1]][l] * 2 + (fl > k)));
                        // cerr << i << " " << j << " " << num[fl][k] * 2 + op << " " << id(i, j, num[fl][k] * 2 + op) << " 3\n"; 
                    }
                }
            }
        }
    // for(int x : edge[17])   cerr << x << " ";
    // cerr << "\n";
    bfs();
    // cerr << id(edx, edy, 0) << " " << id(edx, edy, 5) << "\n";
    for(int i = id(edx, edy, 0); i <= id(edx, edy, 5); ++i) ans = min(ans, dis[i]);
    cout << (ans > n * n ? -1 : ans);
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 11052kb

input:

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

output:

6

result:

ok 1 number(s): "6"

Test #2:

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

input:

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

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

score: 0
Accepted
time: 3ms
memory: 11040kb

input:

2
4
1 3 3
2 3

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

2
4
1 2 3
2 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 6ms
memory: 12228kb

input:

100
4
1 2 3
4 3 1 1 4
1 3 3 4 1 2 3
2 2 2 1 2 2 2 4 4
4 1 2 4 2 1 4 2 1 2 2
4 3 3 1 2 4 2 1 4 4 2 3 4
3 2 3 1 1 4 2 4 3 2 3 4 1 4 3
4 4 2 1 3 3 2 1 4 3 3 3 4 3 2 1 2
1 2 4 3 1 1 4 4 1 2 3 3 4 1 3 4 2 2 2
1 3 2 2 4 3 4 1 4 3 2 2 4 3 2 1 4 4 2 1 3
3 2 2 4 4 4 1 4 1 2 3 1 3 2 3 4 1 2 3 4 1 1 3
2 2 4 2 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #6:

score: 0
Accepted
time: 6ms
memory: 12184kb

input:

100
4
1 3 3
2 3 2 1 4
1 1 1 4 1 4 3
4 2 2 1 4 3 2 1 4
4 3 3 4 1 2 2 4 3 4 2
4 3 2 1 1 2 2 1 4 4 2 1 2
1 2 3 4 1 2 1 4 4 4 3 4 1 4 3
1 3 4 2 3 4 3 1 4 2 2 1 4 1 1 3 4
2 2 3 4 3 2 2 4 4 1 3 4 2 2 3 4 3 1 3
3 3 3 2 4 3 2 2 4 3 1 1 4 3 1 1 4 1 2 2 3
1 2 2 4 3 2 3 3 2 4 3 4 1 2 2 4 3 1 4 4 1 2 3
4 4 4 2 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #7:

score: 0
Accepted
time: 3ms
memory: 12328kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 2 3 1 1 4
2 3 4 2 4 3 2 3 4
4 2 3 4 1 2 3 1 1 2 3
1 3 1 3 4 4 2 1 2 1 2 3 4
2 1 1 4 1 1 3 4 2 3 3 4 1 2 3
1 1 2 1 1 3 2 1 1 3 2 1 1 3 2 3 4
2 2 1 4 1 2 2 4 1 4 2 2 1 1 3 3 1 4 3
4 2 2 4 4 3 2 1 4 3 2 2 1 4 2 1 4 3 4 2 4
1 2 3 3 1 2 3 2 1 2 3 4 2 1 3 4 4 3 3 2 1 2 3
2 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

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

input:

100
4
1 1 4
4 3 2 1 4
3 2 1 4 1 4 3
1 3 3 1 2 2 3 3 3
1 2 3 1 1 2 3 2 1 1 1
1 3 2 1 4 3 2 1 4 3 2 1 1
2 2 3 3 3 2 3 4 4 3 3 4 1 3 4
4 3 2 3 4 1 2 1 4 3 1 1 2 2 1 1 1
1 2 3 2 1 1 2 4 3 2 3 4 1 2 3 4 1 3 3
4 4 3 2 4 3 2 3 3 3 3 2 4 3 2 1 3 3 2 1 4
2 2 3 4 1 2 3 4 3 2 3 4 3 2 3 4 4 2 1 4 1 2 3
4 3 4 4 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #9:

score: 0
Accepted
time: 3ms
memory: 12064kb

input:

100
4
1 4 3
4 3 3 1 4
1 2 3 4 1 2 3
1 3 1 1 4 3 2 1 4
1 2 3 2 2 1 1 4 3 2 4
4 3 1 3 4 3 3 2 2 3 1 3 2
3 2 4 4 1 2 3 3 1 4 3 4 1 3 1
4 4 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 3 1 3 4 1 2 1 4 1 2 3 4 1 1 3
2 3 2 1 2 3 2 1 4 4 2 1 2 3 2 1 4 3 1 1 4
1 2 4 4 1 3 3 4 1 2 2 4 1 2 3 4 4 4 3 2 1 2 1
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #10:

score: 0
Accepted
time: 6ms
memory: 11972kb

input:

100
4
4 1 3
4 3 2 1 1
4 2 2 4 1 2 4
2 3 1 2 1 3 2 1 4
1 3 3 4 1 2 1 4 1 4 3
3 3 2 1 1 3 2 2 4 3 2 1 4
1 2 3 1 1 2 3 4 1 3 3 3 1 2 1
4 1 2 1 4 3 2 1 4 2 2 1 4 3 2 1 4
2 4 3 2 1 2 3 2 1 3 3 4 2 2 3 4 1 2 3
4 3 2 1 4 2 2 2 4 3 2 1 4 2 2 1 3 3 4 4 4
1 2 3 1 3 2 3 4 2 2 3 4 1 2 3 4 1 2 2 4 1 3 1
4 3 2 2 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #11:

score: 0
Accepted
time: 3ms
memory: 12000kb

input:

100
4
1 2 3
1 3 2 1 2
1 2 2 4 4 4 3
2 3 2 3 4 3 2 1 4
1 2 4 4 1 2 1 4 1 4 3
2 3 1 1 2 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 4 3 4 3 2 3
4 3 2 1 4 3 2 2 4 3 2 1 4 3 2 1 4
1 2 3 4 1 1 3 4 4 3 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 4 1 1 3 3 2 4 4 2 1 4 3 2 3 3
1 2 3 4 1 2 4 4 1 2 1 4 1 2 3 3 4 3 2 4 1 3 3
2 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #12:

score: 0
Accepted
time: 3ms
memory: 12072kb

input:

100
4
4 2 3
4 3 2 1 3
1 3 2 4 1 2 3
4 3 2 1 3 3 4 1 3
1 2 3 1 1 1 3 1 1 2 3
4 3 2 1 4 3 2 1 4 3 2 4 1
1 2 3 4 1 2 4 4 1 3 2 4 1 4 1
3 1 2 2 4 3 4 1 1 1 2 3 4 3 2 1 4
3 2 4 2 2 2 2 1 3 2 3 1 1 1 3 4 1 2 3
4 3 2 2 4 2 2 3 4 2 2 1 4 3 2 1 4 3 2 4 3
1 2 4 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 2
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #13:

score: 0
Accepted
time: 6ms
memory: 12532kb

input:

100
4
1 2 3
4 3 2 4 4
1 2 3 4 4 2 3
4 3 2 4 4 3 3 1 4
3 1 3 4 1 2 3 4 1 2 1
4 3 2 1 4 3 2 1 4 4 3 1 4
1 2 3 4 1 2 3 4 1 2 3 1 1 4 3
4 1 2 3 4 3 2 1 4 3 2 1 4 4 3 1 3
1 2 1 4 2 2 4 4 1 2 3 4 1 2 3 3 2 2 3
4 1 3 1 4 3 2 2 4 1 2 1 3 3 2 1 4 1 2 3 4
1 2 3 4 3 3 1 4 1 2 3 1 1 2 3 4 1 2 3 3 1 2 3
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #14:

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

input:

100
4
1 2 1
2 2 2 1 4
2 2 3 4 1 2 3
4 4 2 2 4 3 2 1 4
1 2 3 3 1 2 1 4 1 2 1
4 3 2 3 4 3 2 1 4 3 2 1 4
1 2 1 4 1 2 3 4 1 2 3 4 1 2 3
2 1 2 1 4 3 2 1 3 4 2 1 4 3 2 1 4
2 3 3 3 1 2 2 4 1 2 3 4 1 3 4 4 2 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 4 3 1 2 3 4 1 4 3 4 4 2 3 2 1 2 3 4 1 3 2
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #15:

score: 0
Accepted
time: 3ms
memory: 12052kb

input:

100
4
1 2 3
4 3 2 2 4
1 2 2 4 1 2 3
4 3 4 1 4 2 2 1 4
1 2 1 4 1 2 3 4 3 2 3
4 3 2 1 4 3 2 1 4 4 3 2 4
2 2 3 4 1 2 2 4 3 2 3 3 1 1 2
4 3 2 1 4 3 2 1 4 2 2 1 4 1 2 1 1
1 1 3 4 1 3 1 4 2 2 3 4 3 2 3 4 1 2 3
4 3 2 1 4 1 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
3 2 3 4 1 2 3 4 1 3 3 3 1 4 3 1 1 2 3 4 1 2 3
4 4 2 1 ...

output:

86

result:

ok 1 number(s): "86"

Test #16:

score: 0
Accepted
time: 6ms
memory: 12096kb

input:

100
4
1 2 3
1 3 2 1 4
1 2 3 4 2 2 3
4 1 2 1 3 3 2 3 4
3 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 2 4 1 2 1 4
1 2 3 4 1 2 1 4 1 2 3 4 2 2 3
4 2 2 1 4 3 2 2 4 3 2 1 3 3 2 1 4
1 2 3 3 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 4 2 1 4 3 2 1 4
1 2 3 4 4 2 3 4 1 2 3 4 1 2 3 2 1 2 4 1 1 2 3
4 3 3 1 ...

output:

207

result:

ok 1 number(s): "207"

Test #17:

score: 0
Accepted
time: 3ms
memory: 12116kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 4 1 2 3
4 3 4 1 4 1 2 1 4
1 2 3 4 1 2 3 3 1 2 3
4 3 2 1 2 3 2 3 4 3 2 1 4
1 2 3 4 4 2 4 4 1 2 3 1 1 2 3
4 3 2 1 4 1 2 1 4 3 2 1 4 3 2 1 1
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 3 1 4 3 2 1 4 3 2 1 1 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 3 3
4 3 1 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #18:

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

input:

100
4
1 2 3
4 3 2 2 2
1 4 3 4 1 2 3
4 3 2 1 4 3 2 1 3
1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 2
1 2 4 1 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 3 3 4 1 3 3 2 1 4 3 1 1 4
1 2 3 4 1 2 1 4 2 2 3 3 1 2 3 4 1 2 3
1 1 2 1 4 3 2 1 4 2 1 1 4 3 2 1 4 3 2 1 4
1 2 1 4 2 4 3 4 1 2 3 4 1 4 3 4 1 2 3 4 1 1 3
4 3 2 1 ...

output:

143

result:

ok 1 number(s): "143"

Test #19:

score: 0
Accepted
time: 6ms
memory: 12252kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 1 4 1 2 3
4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 3 2 3
4 3 1 3 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 1 4 1 2 3
1 3 2 1 4 3 2 1 4 3 1 4 4 3 2 1 4
1 2 3 4 1 4 3 4 1 2 3 4 1 2 3 4 4 2 4
3 3 2 1 4 3 2 4 4 3 2 1 4 4 1 1 4 3 2 1 4
1 2 3 4 1 1 3 4 1 2 3 1 1 2 2 4 1 2 3 4 1 2 3
4 3 2 1 ...

output:

179

result:

ok 1 number(s): "179"

Test #20:

score: 0
Accepted
time: 3ms
memory: 12300kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 2 1 2 2
4 3 2 1 2 1 2 1 4
1 2 3 4 1 2 3 4 1 3 3
4 3 2 1 4 3 2 4 4 3 2 1 4
2 2 3 4 1 2 3 4 1 3 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 4 2 3 4 1 2 3 4 1 2 2 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 2 4 1 2 3 4 3 2 3 4 1 2 3 4 1 2 3 4 2 4 3
4 3 2 1 ...

output:

2

result:

ok 1 number(s): "2"

Test #21:

score: 0
Accepted
time: 6ms
memory: 12156kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 4 1 2 3
4 3 2 4 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 1 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 2 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 4 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #22:

score: 0
Accepted
time: 3ms
memory: 12364kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4
1 3 3 4 1 2 3 4 1 2 3
4 3 2 2 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 3 2 3 4 2 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 3
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 4 3 4 1 2 3 3 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 ...

output:

160

result:

ok 1 number(s): "160"

Test #23:

score: 0
Accepted
time: 3ms
memory: 12020kb

input:

100
4
1 2 3
4 3 1 1 4
1 2 3 4 1 3 3
4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 4
4 3 2 1 4 3 2 1 4 3 2 1 2 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 3 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 1 3 4 1 2 3 4 1 2 3 4 1 4 3
4 3 2 1 ...

output:

24

result:

ok 1 number(s): "24"

Test #24:

score: 0
Accepted
time: 3ms
memory: 12132kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 4 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 3 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 4 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 ...

output:

131

result:

ok 1 number(s): "131"

Test #25:

score: 0
Accepted
time: 6ms
memory: 11940kb

input:

100
4
1 2 3
4 3 2 4 4
1 2 2 4 1 2 3
4 4 2 1 4 2 2 1 4
1 2 3 4 4 2 3 4 4 2 3
4 3 2 2 4 3 2 2 4 3 2 3 4
1 2 2 4 1 2 1 4 1 2 4 4 1 2 3
4 2 2 1 4 4 2 1 4 4 2 1 4 1 2 1 4
1 2 3 4 3 2 3 4 3 2 3 4 3 2 3 4 2 2 3
4 3 2 4 4 3 2 4 4 3 2 2 4 3 2 3 4 3 2 2 4
1 2 2 4 1 2 4 4 1 2 4 4 1 2 4 4 1 2 4 4 1 2 3
4 2 2 1 ...

output:

7352

result:

ok 1 number(s): "7352"

Test #26:

score: 0
Accepted
time: 6ms
memory: 11956kb

input:

100
4
1 2 2
4 3 2 1 4
4 1 4 1 3 2 3
4 3 2 1 4 3 2 1 4
1 2 2 1 4 4 1 2 3 3 2
4 3 2 1 4 3 2 1 4 3 2 1 4
3 3 1 3 3 3 1 3 2 1 2 1 3 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 1 1 4 1 1 3 3 4 1 2 3 1 2 3 3 1 2
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
2 4 2 3 3 3 1 2 2 3 1 3 4 1 1 3 3 1 1 1 4 2 3
4 3 2 1 ...

output:

4996

result:

ok 1 number(s): "4996"

Test #27:

score: 0
Accepted
time: 6ms
memory: 12016kb

input:

100
4
1 2 3
4 3 2 4 4
1 2 1 4 1 2 3
4 4 2 1 4 1 2 1 4
1 2 3 4 4 2 3 4 3 2 3
4 3 2 4 4 3 2 2 4 3 2 3 4
1 2 2 4 1 2 1 4 1 2 2 4 1 2 3
4 4 2 1 4 4 2 1 4 1 2 1 4 2 2 1 4
1 2 3 4 3 2 3 4 4 2 3 4 4 2 3 4 2 2 3
4 3 2 4 4 3 2 2 4 3 2 2 4 3 2 2 4 3 2 3 4
1 2 4 4 1 2 1 4 1 2 2 4 1 2 2 4 1 2 2 4 1 2 3
4 2 2 1 ...

output:

3736

result:

ok 1 number(s): "3736"

Test #28:

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

input:

100
4
1 2 1
4 3 2 1 4
2 1 4 1 3 2 3
4 3 2 1 4 3 2 1 4
1 2 1 2 2 4 2 1 4 1 4
4 3 2 1 4 3 2 1 4 3 2 1 4
2 1 1 2 4 1 1 1 4 4 1 3 3 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 4 3 3 4 2 2 2 4 4 1 4 3 1 3 3 1 2
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
4 1 3 1 4 4 1 1 2 4 1 2 3 4 4 2 3 1 1 2 2 2 3
4 3 2 1 ...

output:

4716

result:

ok 1 number(s): "4716"

Test #29:

score: 0
Accepted
time: 3ms
memory: 12032kb

input:

100
4
1 2 3
4 3 2 4 4
1 2 1 4 1 2 3
4 1 2 1 4 2 2 1 4
1 2 3 4 4 2 3 4 4 2 3
4 3 2 2 4 3 2 4 4 3 2 4 4
1 2 2 4 1 2 1 4 1 2 1 4 1 2 3
4 2 2 1 4 4 2 1 4 1 2 1 4 1 2 1 4
1 2 3 4 4 2 3 4 4 2 3 4 4 2 3 4 4 2 3
4 3 2 3 4 3 2 3 4 3 2 4 4 3 2 4 4 3 2 3 4
1 2 1 4 1 2 2 4 1 2 4 4 1 2 4 4 1 2 1 4 1 2 3
4 2 2 1 ...

output:

2255

result:

ok 1 number(s): "2255"

Test #30:

score: 0
Accepted
time: 3ms
memory: 12036kb

input:

100
4
1 2 2
4 3 2 1 4
3 1 4 1 4 2 3
4 3 2 1 4 3 2 1 4
1 2 1 3 2 4 2 3 4 3 1
4 3 2 1 4 3 2 1 4 3 2 1 4
1 1 2 3 2 4 2 1 4 2 1 3 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 1 1 3 3 1 2 4 1 4 2 4 4 2 2 2 3 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
3 4 1 4 4 3 1 3 2 1 4 1 2 3 4 1 4 4 4 1 1 2 3
4 3 2 1 ...

output:

3598

result:

ok 1 number(s): "3598"

Test #31:

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

input:

100
4
1 2 3
4 3 2 4 4
1 2 2 4 1 2 3
4 2 2 1 4 4 2 1 4
1 2 3 4 2 2 3 4 3 2 3
4 3 2 3 4 3 2 4 4 3 2 3 4
1 2 4 4 1 2 2 4 1 2 2 4 1 2 3
4 4 2 1 4 4 2 1 4 1 2 1 4 1 2 1 4
1 2 3 4 3 2 3 4 3 2 3 4 3 2 3 4 3 2 3
4 3 2 4 4 3 2 3 4 3 2 2 4 3 2 4 4 3 2 4 4
1 2 2 4 1 2 1 4 1 2 3 4 1 2 4 4 1 2 1 4 1 2 3
4 1 2 1 ...

output:

2458

result:

ok 1 number(s): "2458"

Test #32:

score: 0
Accepted
time: 3ms
memory: 11920kb

input:

100
4
1 2 1
4 3 2 1 4
4 1 2 1 2 2 3
4 3 2 1 4 3 2 1 4
1 2 4 2 4 1 3 3 2 1 4
4 3 2 1 4 3 2 1 4 3 2 1 4
4 1 1 2 2 4 2 1 2 4 4 1 2 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 2 2 2 3 1 4 2 4 4 4 4 2 1 2 4 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
2 4 2 2 4 3 1 1 3 2 4 1 2 4 4 1 3 3 4 1 3 2 3
4 3 2 1 ...

output:

2009

result:

ok 1 number(s): "2009"

Test #33:

score: 0
Accepted
time: 6ms
memory: 11948kb

input:

100
4
1 2 3
4 3 2 2 4
1 2 4 4 1 2 3
4 2 2 1 4 1 2 1 4
1 2 3 4 4 2 3 4 2 2 3
4 3 2 2 4 3 2 4 4 3 2 4 4
1 2 4 4 1 2 4 4 1 2 2 4 1 2 3
4 1 2 1 4 2 2 1 4 2 2 1 4 4 2 1 4
1 2 3 4 3 2 3 4 4 2 3 4 3 2 3 4 2 2 3
4 3 2 4 4 3 2 2 4 3 2 4 4 3 2 4 4 3 2 2 4
1 2 1 4 1 2 1 4 1 2 2 4 1 2 4 4 1 2 4 4 1 2 3
4 2 2 1 ...

output:

1638

result:

ok 1 number(s): "1638"

Test #34:

score: 0
Accepted
time: 3ms
memory: 12260kb

input:

100
4
1 2 2
4 3 2 1 4
1 1 4 3 2 2 3
4 3 2 1 4 3 2 1 4
1 2 3 3 3 1 2 1 3 1 3
4 3 2 1 4 3 2 1 4 3 2 1 4
4 4 2 3 4 2 2 4 2 1 4 2 3 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 3 3 4 3 4 2 3 3 2 1 4 2 2 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
2 3 3 2 3 3 2 4 3 2 3 1 2 2 2 3 1 2 4 4 4 2 3
4 3 2 1 ...

output:

1723

result:

ok 1 number(s): "1723"

Test #35:

score: 0
Accepted
time: 6ms
memory: 12008kb

input:

100
4
1 2 3
3 3 2 4 4
1 2 3 4 4 2 3
1 3 2 4 4 3 2 1 4
1 2 3 4 2 2 3 2 1 2 3
3 3 2 2 4 3 2 1 2 3 2 4 4
1 2 3 4 2 2 3 2 1 2 3 4 4 2 3
3 3 2 4 4 3 2 1 1 3 2 2 4 3 2 1 4
1 2 3 4 4 2 3 3 1 2 3 4 2 2 3 2 1 2 3
1 3 2 4 4 3 2 1 3 3 2 2 4 3 2 1 2 3 2 2 4
1 2 3 4 2 2 3 2 1 2 3 4 4 2 3 1 1 2 3 4 3 2 3
1 3 2 3 ...

output:

7352

result:

ok 1 number(s): "7352"

Test #36:

score: 0
Accepted
time: 3ms
memory: 12244kb

input:

100
4
2 2 3
1 2 2 1 3
4 4 3 4 2 3 3
3 2 2 1 3 2 2 1 4
4 3 3 4 4 4 3 4 4 2 3
1 4 2 1 3 2 2 1 2 4 2 1 3
3 4 3 4 2 3 3 4 2 3 3 4 4 4 3
2 4 2 1 3 1 2 1 3 1 2 1 1 1 2 1 4
4 4 3 4 2 3 3 4 4 3 3 4 4 4 3 4 4 2 3
1 4 2 1 1 4 2 1 3 4 2 1 2 1 2 1 2 4 2 1 2
4 1 3 4 3 4 3 4 2 1 3 4 4 4 3 4 4 1 3 4 4 1 3
1 4 2 1 ...

output:

4998

result:

ok 1 number(s): "4998"

Test #37:

score: 0
Accepted
time: 6ms
memory: 12244kb

input:

100
4
1 2 3
1 3 2 4 4
1 2 3 4 4 2 3
2 3 2 4 4 3 2 1 4
1 2 3 4 3 2 3 4 1 2 3
1 3 2 2 4 3 2 1 1 3 2 4 4
1 2 3 4 2 2 3 2 1 2 3 4 3 2 3
3 3 2 2 4 3 2 1 2 3 2 4 4 3 2 1 4
1 2 3 4 4 2 3 1 1 2 3 4 2 2 3 3 1 2 3
2 3 2 2 4 3 2 1 2 3 2 2 4 3 2 1 1 3 2 2 4
1 2 3 4 2 2 3 3 1 2 3 4 4 2 3 2 1 2 3 4 3 2 3
1 3 2 3 ...

output:

3288

result:

ok 1 number(s): "3288"

Test #38:

score: 0
Accepted
time: 3ms
memory: 12044kb

input:

100
4
1 2 3
1 2 2 1 2
3 4 3 4 4 1 3
2 3 2 1 2 4 2 1 4
3 1 3 4 4 3 3 4 4 2 3
3 2 2 1 3 2 2 1 2 4 2 1 3
3 1 3 4 4 3 3 4 4 1 3 4 2 4 3
2 1 2 1 2 2 2 1 2 2 2 1 3 2 2 1 4
2 1 3 4 3 3 3 4 3 1 3 4 4 4 3 4 3 2 3
2 1 2 1 2 1 2 1 2 4 2 1 3 4 2 1 1 4 2 1 1
2 1 3 4 1 4 3 4 3 4 3 4 3 4 3 4 2 4 3 4 3 3 3
2 2 2 1 ...

output:

4607

result:

ok 1 number(s): "4607"

Test #39:

score: 0
Accepted
time: 6ms
memory: 12000kb

input:

100
4
1 2 3
1 3 2 2 4
1 2 3 4 2 2 3
3 3 2 2 4 3 2 1 4
1 2 3 4 3 2 3 2 1 2 3
1 3 2 3 4 3 2 1 1 3 2 3 4
1 2 3 4 2 2 3 1 1 2 3 4 3 2 3
1 3 2 2 4 3 2 1 2 3 2 2 4 3 2 1 4
1 2 3 4 2 2 3 1 1 2 3 4 4 2 3 2 1 2 3
1 3 2 3 4 3 2 1 4 3 2 3 4 3 2 1 2 3 2 3 4
1 2 3 4 3 2 3 1 1 2 3 4 3 2 3 2 1 2 3 4 2 2 3
2 3 2 3 ...

output:

2271

result:

ok 1 number(s): "2271"

Test #40:

score: 0
Accepted
time: 6ms
memory: 12252kb

input:

100
4
4 2 3
2 2 2 1 3
2 4 3 4 2 4 3
1 2 2 1 3 2 2 1 4
2 1 3 4 3 4 3 4 2 2 3
2 4 2 1 3 1 2 1 1 2 2 1 1
2 1 3 4 1 3 3 4 4 4 3 4 2 3 3
3 4 2 1 3 4 2 1 1 1 2 1 2 1 2 1 4
4 3 3 4 4 1 3 4 3 1 3 4 3 4 3 4 2 2 3
3 4 2 1 1 1 2 1 2 4 2 1 3 4 2 1 2 1 2 1 2
3 1 3 4 2 4 3 4 4 3 3 4 4 4 3 4 2 1 3 4 4 4 3
2 2 2 1 ...

output:

2950

result:

ok 1 number(s): "2950"

Test #41:

score: 0
Accepted
time: 3ms
memory: 12220kb

input:

100
4
1 2 3
1 3 2 4 4
1 2 3 4 3 2 3
1 3 2 2 4 3 2 1 4
1 2 3 4 4 2 3 1 1 2 3
2 3 2 3 4 3 2 1 3 3 2 2 4
1 2 3 4 3 2 3 3 1 2 3 4 3 2 3
3 3 2 3 4 3 2 1 3 3 2 2 4 3 2 1 4
1 2 3 4 4 2 3 1 1 2 3 4 3 2 3 2 1 2 3
1 3 2 2 4 3 2 1 3 3 2 4 4 3 2 1 1 3 2 4 4
1 2 3 4 2 2 3 3 1 2 3 4 4 2 3 1 1 2 3 4 2 2 3
1 3 2 3 ...

output:

1618

result:

ok 1 number(s): "1618"

Test #42:

score: 0
Accepted
time: 6ms
memory: 12248kb

input:

100
4
2 2 3
2 2 2 1 1
2 1 3 4 2 4 3
4 1 2 1 2 3 2 1 4
2 3 3 4 4 3 3 4 3 2 3
2 1 2 1 2 1 2 1 3 4 2 1 3
1 1 3 4 4 3 3 4 2 3 3 4 4 3 3
3 1 2 1 2 3 2 1 4 4 2 1 3 1 2 1 4
4 3 3 4 3 4 3 4 2 4 3 4 3 4 3 4 4 2 3
1 1 2 1 3 1 2 1 1 2 2 1 4 2 2 1 1 4 2 1 4
2 4 3 4 4 4 3 4 3 4 3 4 2 4 3 4 4 3 3 4 1 1 3
4 4 2 1 ...

output:

2054

result:

ok 1 number(s): "2054"

Test #43:

score: 0
Accepted
time: 3ms
memory: 11952kb

input:

100
4
1 2 3
3 3 2 4 4
1 2 3 4 2 2 3
4 3 2 2 4 3 2 1 4
1 2 3 4 2 2 3 1 1 2 3
4 3 2 4 4 3 2 1 2 3 2 3 4
1 2 3 4 2 2 3 3 1 2 3 4 4 2 3
3 3 2 2 4 3 2 1 1 3 2 3 4 3 2 1 4
1 2 3 4 3 2 3 1 1 2 3 4 3 2 3 3 1 2 3
1 3 2 4 4 3 2 1 3 3 2 4 4 3 2 1 2 3 2 4 4
1 2 3 4 3 2 3 2 1 2 3 4 3 2 3 1 1 2 3 4 2 2 3
1 3 2 2 ...

output:

1217

result:

ok 1 number(s): "1217"

Test #44:

score: 0
Accepted
time: 6ms
memory: 12264kb

input:

100
4
2 2 3
1 1 2 1 1
1 3 3 4 2 1 3
3 2 2 1 1 4 2 1 4
1 1 3 4 4 3 3 4 3 2 3
1 4 2 1 2 2 2 1 3 1 2 1 1
2 1 3 4 2 3 3 4 4 3 3 4 3 1 3
1 1 2 1 3 4 2 1 2 2 2 1 3 4 2 1 4
3 3 3 4 1 1 3 4 4 4 3 4 4 1 3 4 3 2 3
3 1 2 1 3 4 2 1 3 2 2 1 2 3 2 1 4 1 2 1 2
2 3 3 4 4 4 3 4 4 3 3 4 4 1 3 4 3 3 3 4 4 1 3
4 2 2 1 ...

output:

1546

result:

ok 1 number(s): "1546"

Test #45:

score: 0
Accepted
time: 3ms
memory: 12108kb

input:

100
4
3 2 3
4 3 2 1 3
1 2 1 1 1 2 3
2 3 2 1 4 1 2 1 2
1 2 3 3 1 2 2 4 1 2 3
4 4 2 1 4 3 1 2 3 4 2 1 4
1 2 4 4 1 1 3 4 1 4 3 4 1 3 3
4 3 2 3 4 3 4 1 3 3 2 1 2 3 2 1 2
1 2 3 3 1 2 2 3 3 1 2 4 2 2 3 4 1 2 3
4 3 3 1 2 3 2 1 4 4 2 1 4 3 2 2 4 3 1 1 4
1 2 3 1 1 2 3 1 2 2 3 4 4 4 3 4 1 1 3 4 2 2 3
4 3 4 4 ...

output:

320

result:

ok 1 number(s): "320"

Test #46:

score: 0
Accepted
time: 6ms
memory: 11992kb

input:

100
4
4 2 3
4 3 3 1 4
1 2 3 3 1 2 4
4 3 2 3 4 3 1 1 4
2 2 3 3 1 2 4 4 1 2 3
4 3 2 1 2 3 2 1 4 4 2 1 4
1 2 1 4 1 2 3 1 1 2 2 4 4 2 3
4 3 2 4 4 3 1 4 4 3 3 1 4 3 2 1 4
1 2 4 4 1 4 3 4 1 2 4 4 1 2 3 1 1 2 3
4 3 4 4 1 3 2 1 2 4 2 1 4 4 3 1 4 1 2 1 4
1 2 2 4 1 2 3 2 1 2 3 4 4 2 3 4 1 1 1 4 1 4 2
4 3 3 1 ...

output:

1027

result:

ok 1 number(s): "1027"

Test #47:

score: 0
Accepted
time: 3ms
memory: 12172kb

input:

100
4
1 2 1
2 3 2 1 4
1 2 3 1 1 2 2
4 3 1 1 4 3 3 1 4
4 2 3 4 1 1 3 4 1 2 3
4 3 2 3 4 3 4 1 4 2 2 1 4
1 2 3 3 1 2 1 4 1 2 3 2 3 2 3
4 1 2 1 3 3 2 1 4 1 4 1 4 3 2 2 4
1 2 3 4 1 2 3 1 4 2 3 4 1 1 3 4 1 2 3
4 3 3 1 4 2 4 1 4 3 2 3 3 3 2 3 4 2 2 1 4
1 2 3 4 4 2 3 4 1 3 3 4 1 2 2 4 1 2 3 4 2 2 3
4 4 2 1 ...

output:

1147

result:

ok 1 number(s): "1147"

Test #48:

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

input:

100
4
1 2 3
4 1 2 1 1
1 2 2 4 1 2 3
4 3 2 1 2 1 2 1 3
1 2 3 3 1 2 3 4 3 2 3
4 3 4 1 3 3 2 3 4 3 1 1 4
1 2 3 4 1 2 3 4 3 2 3 4 1 2 3
4 3 3 1 4 1 2 4 4 3 2 3 4 3 1 1 4
3 2 3 4 1 4 3 4 1 2 1 4 4 2 3 4 3 2 3
4 3 2 2 4 3 1 1 2 3 2 1 4 3 2 1 1 4 3 1 4
1 2 2 4 4 2 3 2 1 2 3 4 2 3 3 2 1 2 3 4 2 2 3
4 3 2 1 ...

output:

2292

result:

ok 1 number(s): "2292"

Test #49:

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

input:

100
4
1 2 4
3 3 2 1 4
1 2 3 2 1 2 3
4 3 1 1 2 3 1 1 4
1 2 3 4 1 2 3 4 2 2 3
4 3 3 1 4 1 2 1 4 3 3 1 4
1 4 3 4 1 3 3 4 4 2 2 4 1 2 3
4 3 2 1 1 3 2 1 4 4 2 1 4 3 1 1 4
3 2 3 3 1 2 3 4 1 3 3 4 4 4 3 4 1 3 3
4 3 2 1 1 3 2 3 4 1 2 1 3 3 2 1 1 3 2 1 3
1 2 3 3 1 2 3 4 3 2 3 4 1 4 3 4 1 2 2 2 1 2 3
4 3 4 1 ...

output:

67

result:

ok 1 number(s): "67"

Test #50:

score: 0
Accepted
time: 6ms
memory: 12032kb

input:

100
4
4 2 3
4 3 1 1 4
1 2 3 2 1 2 1
4 3 2 4 3 3 2 1 4
1 3 3 4 1 2 4 4 1 1 3
4 3 2 1 4 1 2 1 4 3 4 1 4
1 2 2 4 1 3 1 4 1 1 2 4 1 2 3
2 3 2 1 1 3 2 1 3 3 2 1 4 2 2 1 4
1 2 3 4 1 3 3 4 3 2 3 3 2 2 3 3 1 2 3
4 3 3 1 2 3 4 1 4 3 2 1 4 3 4 1 4 1 2 1 4
3 3 3 4 1 2 3 4 1 4 3 4 1 3 2 1 4 2 3 1 1 2 3
4 2 2 1 ...

output:

532

result:

ok 1 number(s): "532"

Test #51:

score: 0
Accepted
time: 9ms
memory: 12248kb

input:

100
4
2 2 3
4 3 2 1 3
3 2 3 3 1 2 3
4 3 4 1 4 2 2 1 4
1 2 3 4 1 2 1 4 4 2 3
4 3 2 3 4 1 2 1 4 3 2 1 4
4 2 3 3 1 2 3 3 1 2 3 1 1 2 4
4 3 1 1 4 3 1 1 4 3 3 1 2 3 2 1 4
1 2 3 4 1 1 4 4 1 3 3 4 1 2 3 1 1 2 3
4 3 3 1 2 3 2 1 4 3 2 4 4 3 3 1 2 3 2 3 4
1 2 4 4 1 3 3 4 2 2 2 4 1 2 3 3 1 2 2 4 1 2 3
1 3 2 3 ...

output:

275

result:

ok 1 number(s): "275"

Test #52:

score: 0
Accepted
time: 6ms
memory: 11980kb

input:

100
4
4 2 3
4 3 1 1 4
1 2 3 3 1 2 2
4 2 2 1 4 3 3 1 4
1 2 3 4 2 1 3 4 1 2 3
4 2 2 1 1 3 2 1 4 2 2 1 4
1 2 2 4 1 2 2 4 1 3 3 4 4 2 3
4 3 2 1 1 3 2 1 4 1 2 1 1 3 2 1 4
3 4 3 4 4 2 3 2 2 2 3 4 3 2 3 4 2 2 3
4 1 2 1 4 3 2 1 4 3 2 2 1 2 1 1 4 3 2 3 4
1 2 3 4 3 4 3 2 1 1 4 4 1 1 3 4 1 1 4 4 1 2 3
4 3 2 2 ...

output:

54

result:

ok 1 number(s): "54"

Test #53:

score: 0
Accepted
time: 3ms
memory: 12008kb

input:

100
4
1 2 1
4 3 1 1 4
1 2 2 3 3 2 3
3 3 2 1 4 3 2 1 4
1 2 3 1 1 4 1 2 1 2 4
4 3 2 4 4 3 2 2 4 3 3 1 4
1 2 1 4 1 2 4 4 1 2 2 3 3 2 3
4 3 3 4 2 1 2 1 4 2 2 1 4 3 2 1 4
4 2 3 4 1 4 3 4 4 2 3 4 3 2 1 4 1 4 3
4 3 2 4 3 3 2 2 4 3 2 1 2 4 3 1 4 3 2 1 4
1 2 4 4 1 2 4 4 1 3 4 4 1 2 3 4 1 4 3 4 2 2 3
2 3 2 3 ...

output:

1360

result:

ok 1 number(s): "1360"

Test #54:

score: 0
Accepted
time: 3ms
memory: 12052kb

input:

100
4
3 2 3
4 3 1 1 4
1 2 3 1 1 2 4
3 2 2 1 3 3 2 1 4
1 4 3 4 1 2 3 2 1 2 4
4 3 2 1 1 3 2 2 4 3 1 1 4
1 2 3 1 1 2 2 4 1 2 1 4 1 2 3
4 3 2 4 4 3 2 1 4 4 2 1 4 4 2 1 4
1 1 3 4 2 2 3 1 1 2 3 2 1 2 3 4 1 1 3
4 3 2 1 2 3 2 1 1 3 1 1 4 2 2 1 1 3 2 1 4
1 3 3 4 4 2 3 4 3 2 3 4 1 2 1 4 1 2 3 1 1 2 1
4 3 3 1 ...

output:

2448

result:

ok 1 number(s): "2448"

Test #55:

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

input:

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

output:

-1

result:

ok 1 number(s): "-1"

Extra Test:

score: 0
Extra Test Passed