QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#318805#5446. 琪露诺的符卡交换catagory100 ✓140ms11328kbC++233.3kb2024-01-31 20:49:502024-01-31 20:49:50

Judging History

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

  • [2024-01-31 20:49:50]
  • 评测
  • 测评结果:100
  • 用时:140ms
  • 内存:11328kb
  • [2024-01-31 20:49:50]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define SZ(x) ((LL)(x.size()))
using namespace std;
long long read(){
  long long q=0,w=1;
  char ch=getchar();
  while(ch>'9' || ch<'0'){if(ch=='-')w=-1;ch=getchar();}
  while(ch>='0'&&ch<='9'){q=q*10+(ch-'0');ch=getchar();}
  return q*w;
}
void write(LL x){
  if(x<0){putchar('-');x=(-x);}
  if(x>9)write(x/10);
  putchar('0'+x%10);
}
void writeln(LL x){write(x);puts("");}
void writecs(LL x){write(x);putchar(' ');}

template<LL N,LL M>struct dinic{
  struct Edge{
    LL to,nxt,w;
  }e[M<<1];LL head[N],cur[N],tot;
  void add(LL u,LL v,LL w){
    e[++tot].to=v;e[tot].nxt=head[u];
    e[tot].w=w;head[u]=tot;return ;
  }
  void add_e(LL u,LL v,LL w){
    //    cout<<"> add_e: u = "<<u<<" v = "<<v<<" w = "<<w<<endl;
    add(u,v,w);add(v,u,0);
  }
  LL n,S,T;
  void clear(){
    for(LL i=1;i<=n;i++)head[i]=cur[i]=0;
    n=S=T=0;tot=1;return ;
  }
  LL dep[N];
  bool bfs(){
    for(LL i=1;i<=n;i++){dep[i]=-1;cur[i]=head[i];}
    queue<LL>q;q.push(S);dep[S]=0;
    while(!q.empty()){
      LL x=q.front();q.pop();
      for(LL i=head[x];i;i=e[i].nxt)
	if(dep[e[i].to]==-1&&e[i].w){dep[e[i].to]=dep[x]+1;q.push(e[i].to);}
    }
    return (dep[T]!=-1);
  }
  LL dfs(LL x,LL flow){
    if(x==T)return flow;
    LL lastflow=flow;
    for(LL i=cur[x];i&&flow;i=e[i].nxt){
      cur[x]=i;
      if(dep[e[i].to]==dep[x]+1&&e[i].w){
	LL d=dfs(e[i].to,min(flow,e[i].w));
	if(d){e[i].w-=d;e[i^1].w+=d;flow-=d;}
      }
    }
    if(lastflow==flow)dep[x]=-1;
    return lastflow-flow;
  }
  LL solve(){
    LL maxflow=0;
    while(bfs())maxflow+=dfs(S,(LL)(1e18));
    return maxflow;
  }
};

#define PLL pair<LL,LL>
#define mp(a,b) make_pair(a,b)
#define fir first
#define sec second
const long long N = 200+95;
long long TC,n,_a[N][N];vector<PLL>a[N][N];PLL b[N][N];dinic<(N<<1)+2,(N*N+(N<<1))>T;
int main(){
  TC=read();
  while(TC--){
    n=read();
    for(LL i=1;i<=n;i++)
      for(LL j=1;j<=n;j++){LL x=read();a[i][x].push_back(mp(i,j));_a[i][j]=x;}
    
    vector<vector<LL>>tmp(n+2);
    for(LL i=1;i<=n;i++)tmp[i].resize(n+2);
    
    for(LL K=1;K<=n;K++){
      //      cout<<"> K = "<<K<<endl;
      T.clear();LL Id=0;LL s=++Id,t=++Id;
      vector<LL>idxL(n+2),idxR(n+2);
      for(LL i=1;i<=n;i++){
	idxL[i]=++Id;T.add_e(s,idxL[i],1);
	idxR[i]=++Id;T.add_e(idxR[i],t,1);
      }
      for(LL i=1;i<=n;i++)
	for(LL j=1;j<=n;j++)
	  if(SZ(a[i][j])){tmp[i][j]=T.tot+1;T.add_e(idxL[i],idxR[j],1);}
      T.n=Id;T.S=s;T.T=t;
      LL maxflow=T.solve();
      //      cerr<<" maxflow = "<<maxflow<<endl;
      assert(maxflow==n);
      for(LL i=1;i<=n;i++)
	for(LL j=1;j<=n;j++)
	  if(SZ(a[i][j])&&!T.e[tmp[i][j]].w){
	    //	    cout<<" -> i = "<<i<<" j = "<<j<<endl;
	    b[i][K]=a[i][j].back();a[i][j].pop_back();}
    }
    vector<vector<LL>>ans;
    for(LL i=1;i<=n;i++)
      for(LL j=i+1;j<=n;j++)
	ans.push_back({b[i][j].fir,b[i][j].sec,b[j][i].fir,b[j][i].sec});
    writeln(SZ(ans));
    for(LL i=0;i<SZ(ans);i++){
      for(LL j=0;j<SZ(ans[i]);j++)writecs(ans[i][j]);
      puts("");
      swap(_a[ans[i][0]][ans[i][1]],_a[ans[i][2]][ans[i][3]]);
    }
    /*    for(LL i=1;i<=n;i++){
      for(LL j=1;j<=n;j++)writecs(_a[i][j]);
      puts("");
    }*/
  }
  return 0;
}

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

详细

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 4ms
memory: 6252kb

input:

7
132
96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 ...

output:

8646
1 131 2 132 
1 130 3 132 
1 129 4 132 
1 128 5 132 
1 127 6 132 
1 126 7 132 
1 125 8 132 
1 124 9 132 
1 123 10 132 
1 122 11 132 
1 121 12 132 
1 120 13 132 
1 119 14 132 
1 118 15 132 
1 117 16 132 
1 116 17 132 
1 115 18 132 
1 114 19 132 
1 113 20 132 
1 112 21 132 
1 111 22 132 
1 110 23 ...

result:

ok your solution is correct.

Test #2:

score: 0
Accepted
time: 4ms
memory: 6744kb

input:

8
14
13 13 13 13 13 13 13 13 13 13 13 13 13 13
7 7 7 7 7 7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8 8 8 8 8 8
14 14 14 14 14 14 14 14 14 14 14 14 14 14
5 5 5 5 5 5 5 5 5 5 5 5 5 5
4 4 4 4 4 4 4 4 4 4 4 4 4 4
1 1 1 1 1 1 1 1 1 1 1 1 1 1
10 10 10 10 10 10 10 10 10 10 10 10 10 10
2 2 2 2 2 2 2 2 2 2 2 2 2 2
9...

output:

91
1 13 2 14 
1 12 3 14 
1 11 4 14 
1 10 5 14 
1 9 6 14 
1 8 7 14 
1 7 8 14 
1 6 9 14 
1 5 10 14 
1 4 11 14 
1 3 12 14 
1 2 13 14 
1 1 14 14 
2 12 3 13 
2 11 4 13 
2 10 5 13 
2 9 6 13 
2 8 7 13 
2 7 8 13 
2 6 9 13 
2 5 10 13 
2 4 11 13 
2 3 12 13 
2 2 13 13 
2 1 14 13 
3 11 4 12 
3 10 5 12 
3 9 6 12...

result:

ok your solution is correct.

Test #3:

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

input:

4
82
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

3321
1 81 2 82 
1 80 3 82 
1 79 4 82 
1 78 5 82 
1 77 6 82 
1 76 7 82 
1 75 8 82 
1 74 9 82 
1 73 10 82 
1 72 11 82 
1 71 12 82 
1 70 13 82 
1 69 14 82 
1 68 15 82 
1 67 16 82 
1 66 17 82 
1 65 18 82 
1 64 19 82 
1 63 20 82 
1 62 21 82 
1 61 22 82 
1 60 23 82 
1 59 24 82 
1 58 25 82 
1 57 26 82 
1 5...

result:

ok your solution is correct.

Test #4:

score: 0
Accepted
time: 10ms
memory: 8804kb

input:

8
3
1 1 1
3 3 3
2 2 2
3
1 1 1
3 3 3
2 2 2
1
1
11
5 5 5 5 5 5 5 5 5 5 5
3 3 3 3 3 3 3 3 3 3 3
1 1 1 1 1 1 1 1 1 1 1
9 9 9 9 9 9 9 9 9 9 9
4 4 4 4 4 4 4 4 4 4 4
11 11 11 11 11 11 11 11 11 11 11
2 2 2 2 2 2 2 2 2 2 2
6 6 6 6 6 6 6 6 6 6 6
8 8 8 8 8 8 8 8 8 8 8
10 10 10 10 10 10 10 10 10 10 10
7 7 7 7 7...

output:

3
1 2 2 3 
1 1 3 3 
2 1 3 2 
3
1 2 2 3 
1 1 3 3 
2 1 3 2 
0
55
1 10 2 11 
1 9 3 11 
1 8 4 11 
1 7 5 11 
1 6 6 11 
1 5 7 11 
1 4 8 11 
1 3 9 11 
1 2 10 11 
1 1 11 11 
2 9 3 10 
2 8 4 10 
2 7 5 10 
2 6 6 10 
2 5 7 10 
2 4 8 10 
2 3 9 10 
2 2 10 10 
2 1 11 10 
3 8 4 9 
3 7 5 9 
3 6 6 9 
3 5 7 9 
3 4 8 ...

result:

ok your solution is correct.

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 20
Accepted
time: 10ms
memory: 6900kb

input:

5
17
9 9 9 9 9 9 9 9 9 9 9 9 9 2 9 9 9
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6
2 2 2 2 2 2 2 2 2 2 2 2 11 2 2 2 2
4 4 4 4 4 4 10 4 4 4 4 4 4 4 4 4 4
10 10 10 10 10 10 8 10 10 10 10 10 10 10 10 10 10
12 12 12 12 12 12 12 12 12 12 12 12 14 12 12 12 12
14 14 14 14 14 14 14 14 14 14 14 12 14 14 14 14 14
16 16...

output:

136
1 16 2 16 
1 15 3 17 
1 13 4 17 
1 12 5 17 
1 11 6 17 
1 10 7 17 
1 9 8 17 
1 8 9 17 
1 7 10 17 
1 6 11 17 
1 5 12 17 
1 4 13 17 
1 3 14 16 
1 2 15 17 
1 1 16 17 
1 14 17 17 
2 14 3 16 
2 13 4 16 
2 12 5 16 
2 11 6 16 
2 10 7 16 
2 9 8 16 
2 8 9 16 
2 7 10 16 
2 6 11 16 
2 5 12 16 
2 4 13 16 
2 ...

result:

ok your solution is correct.

Test #6:

score: 0
Accepted
time: 10ms
memory: 6612kb

input:

9
1
1
28
2 2 2 2 5 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
7 24 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 8 13 13 13
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 16 8 8 8 8 8 8 8 8 8 8 8 8
17 24 24 24 24 24 24 24 24 24 24 24 24...

output:

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

result:

ok your solution is correct.

Test #7:

score: 0
Accepted
time: 7ms
memory: 7184kb

input:

9
22
19 19 19 19 19 19 19 19 19 10 19 19 19 19 19 19 19 19 19 19 19 19
17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 8
21 21 21 21 21 21 21 21 5 21 21 21 21 21 21 21 21 21 21 21 21 21
12 12 12 12 12 12 12 22 12 12 12 12 12 12 12 12 12 12 12 12 12 12
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

231
1 22 2 22 
1 21 3 9 
1 20 4 22 
1 19 5 21 
1 18 6 3 
1 17 7 2 
1 16 8 22 
1 15 9 22 
1 14 10 13 
1 13 11 11 
1 12 12 9 
1 11 13 2 
1 9 14 9 
1 8 15 18 
1 7 16 16 
1 6 17 3 
1 5 18 21 
1 4 19 22 
1 3 20 13 
1 2 21 15 
1 1 22 19 
2 20 3 22 
2 19 4 21 
2 18 5 22 
2 17 6 22 
2 16 7 22 
2 15 8 20 
2 ...

result:

ok your solution is correct.

Test #8:

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

input:

8
29
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 6 3 3 3 3
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 3 11 11 11 11 11 11 11 11
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 23 1 1 1 1 1 1 1
20 20 20 20 20 20 20 20 20 20 20 25 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
26 26...

output:

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

result:

ok your solution is correct.

Subtask #3:

score: 60
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #9:

score: 60
Accepted
time: 2ms
memory: 5820kb

input:

19
1
1
2
1 2
1 2
3
1 3 2
2 3 1
2 1 3
4
1 4 3 4
3 2 2 1
3 1 2 3
4 4 1 2
5
4 2 1 5 4
4 5 4 4 1
5 3 2 3 2
3 1 3 2 1
3 1 2 5 5
6
6 2 2 1 6 6
2 5 5 3 4 6
1 2 4 2 6 1
4 4 1 4 5 1
1 2 6 5 3 5
5 3 3 3 3 4
7
5 2 3 6 4 2 7
2 1 6 1 1 5 2
1 6 7 7 5 1 2
6 6 3 4 4 7 1
3 6 5 7 3 2 7
3 2 5 1 4 5 4
5 3 3 7 4 4 6
8
1...

output:

0
1
1 2 2 2 
3
1 2 2 1 
1 3 3 3 
2 2 3 1 
6
1 4 2 3 
1 3 3 4 
1 2 4 2 
2 4 3 1 
2 1 4 3 
3 2 4 1 
10
1 4 2 4 
1 5 3 5 
1 2 4 3 
1 1 5 5 
2 5 3 3 
2 1 4 1 
2 2 5 2 
3 1 4 4 
3 2 5 4 
4 2 5 1 
15
1 6 2 4 
1 3 3 4 
1 2 4 4 
1 5 5 3 
1 1 6 1 
2 3 3 3 
2 6 4 6 
2 5 5 6 
2 2 6 5 
3 6 4 3 
3 1 5 5 
3 2 6 6...

result:

ok your solution is correct.

Test #10:

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

input:

19
1
1
2
2 1
1 2
3
2 1 2
3 3 3
1 2 1
4
1 2 3 4
1 2 3 4
2 3 1 4
4 1 2 3
5
1 2 3 3 3
4 4 1 2 3
5 2 4 5 1
1 4 5 5 2
5 2 1 4 3
6
1 3 6 6 4 4
5 2 4 6 5 2
3 6 5 6 5 2
1 5 1 4 2 4
3 1 6 3 3 2
3 2 1 4 5 1
7
4 4 1 6 6 7 6
3 7 3 4 5 2 7
6 2 7 6 2 1 3
2 2 5 3 1 2 1
7 3 7 4 2 1 4
5 3 6 3 1 5 5
7 5 6 5 1 4 4
8
6...

output:

0
1
1 1 2 2 
3
1 3 2 3 
1 1 3 2 
2 1 3 3 
6
1 2 2 2 
1 3 3 2 
1 4 4 1 
2 4 3 4 
2 3 4 4 
3 1 4 3 
10
1 5 2 5 
1 2 3 2 
1 4 4 2 
1 3 5 1 
2 3 3 5 
2 2 4 4 
2 1 5 4 
3 4 4 3 
3 1 5 5 
4 5 5 2 
15
1 6 2 6 
1 5 3 1 
1 2 4 6 
1 4 5 3 
1 3 6 5 
2 5 3 4 
2 4 4 2 
2 1 5 5 
2 3 6 6 
3 5 4 5 
3 6 5 4 
3 3 6 3...

result:

ok your solution is correct.

Test #11:

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

input:

19
1
1
2
2 1
1 2
3
3 3 2
1 1 2
2 1 3
4
4 1 1 3
4 4 1 2
1 2 2 3
3 2 4 3
5
3 1 5 5 5
4 2 2 5 2
1 5 4 3 4
1 1 3 4 4
3 1 2 3 2
6
1 5 5 3 2 1
5 5 2 3 4 3
2 6 2 3 1 4
6 6 6 4 6 1
4 5 1 2 3 4
6 3 2 4 5 1
7
5 1 1 3 3 7 7
5 4 1 4 4 3 6
4 4 2 7 1 3 2
1 3 5 6 5 3 5
6 4 2 7 6 2 3
7 2 6 2 1 6 2
5 7 4 5 7 1 6
8
1...

output:

0
1
1 1 2 2 
3
1 3 2 3 
1 1 3 2 
2 1 3 3 
6
1 2 2 4 
1 1 3 4 
1 4 4 3 
2 3 3 3 
2 1 4 4 
3 1 4 1 
10
1 5 2 5 
1 1 3 2 
1 4 4 5 
1 3 5 4 
2 4 3 1 
2 2 4 4 
2 1 5 1 
3 3 4 2 
3 4 5 5 
4 1 5 2 
15
1 1 2 3 
1 4 3 4 
1 5 4 4 
1 3 5 2 
1 2 6 1 
2 2 3 3 
2 1 4 5 
2 5 5 6 
2 4 6 5 
3 5 4 3 
3 2 5 3 
3 6 6 4...

result:

ok your solution is correct.

Test #12:

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

input:

19
1
1
2
2 2
1 1
3
1 1 2
2 1 3
3 2 3
4
2 1 2 3
2 1 3 3
4 4 4 4
2 3 1 1
5
3 5 5 5 4
1 4 4 5 2
1 1 3 1 5
2 4 3 2 3
2 3 4 1 2
6
5 5 4 3 1 1
3 4 1 6 6 6
6 2 2 1 4 4
2 2 6 5 3 3
1 5 6 2 3 3
5 4 1 2 4 5
7
6 4 4 7 7 5 6
1 1 2 1 4 2 7
5 2 5 3 1 1 2
3 4 2 7 6 7 6
5 6 1 2 7 6 4
5 6 5 3 3 7 3
5 4 2 1 3 4 3
8
2...

output:

0
1
1 1 2 2 
3
1 3 2 1 
1 1 3 3 
2 3 3 1 
6
1 4 2 1 
1 3 3 4 
1 1 4 2 
2 4 3 3 
2 3 4 1 
3 1 4 4 
10
1 5 2 5 
1 1 3 4 
1 3 4 5 
1 2 5 3 
2 4 3 5 
2 3 4 4 
2 2 5 2 
3 1 4 2 
3 3 5 5 
4 1 5 1 
15
1 6 2 3 
1 5 3 6 
1 1 4 6 
1 3 5 3 
1 4 6 4 
2 2 3 5 
2 5 4 2 
2 1 5 6 
2 4 6 6 
3 2 4 3 
3 1 5 5 
3 4 6 1...

result:

ok your solution is correct.

Test #13:

score: 0
Accepted
time: 18ms
memory: 8532kb

input:

5
156
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 95 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 34 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 130 1 42 1 1 1 1 1 1 1 1 1 1 1 1 90 1 64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

12090
1 155 2 156 
1 154 3 156 
1 153 4 156 
1 152 5 155 
1 151 6 156 
1 150 7 155 
1 149 8 156 
1 148 9 156 
1 147 10 156 
1 146 11 156 
1 145 12 156 
1 144 13 156 
1 143 14 156 
1 142 15 156 
1 141 16 156 
1 140 17 155 
1 139 18 156 
1 138 19 156 
1 137 20 156 
1 136 21 156 
1 135 22 156 
1 134 23...

result:

ok your solution is correct.

Test #14:

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

input:

7
2
1 2
1 2
4
1 4 4 1
2 3 2 4
1 4 3 3
3 1 2 2
39
1 31 38 1 22 35 1 32 36 19 33 1 1 1 4 14 24 35 33 4 1 31 34 1 1 27 1 1 34 8 35 1 1 38 10 1 6 8 10
22 14 2 2 2 20 9 26 2 8 26 23 2 36 36 2 38 2 2 18 27 29 3 28 2 3 31 33 36 2 20 2 11 33 32 2 2 2 32
34 39 11 34 35 3 3 3 16 3 3 3 34 39 3 27 17 30 33 11 3...

output:

1
1 2 2 2 
6
1 1 2 3 
1 3 3 2 
1 2 4 1 
2 2 3 4 
2 1 4 4 
3 3 4 3 
741
1 33 2 38 
1 32 3 36 
1 28 4 39 
1 27 5 37 
1 25 6 36 
1 24 7 33 
1 21 8 36 
1 14 9 34 
1 13 10 39 
1 12 11 29 
1 7 12 35 
1 37 13 39 
1 39 14 38 
1 4 15 35 
1 1 16 39 
1 38 17 38 
1 35 18 36 
1 20 19 39 
1 15 20 39 
1 31 21 39 
...

result:

ok your solution is correct.

Test #15:

score: 0
Accepted
time: 12ms
memory: 9472kb

input:

7
9
3 8 8 5 7 7 2 5 2
5 9 4 9 8 3 5 7 5
1 2 6 6 9 3 9 6 4
7 6 9 1 7 7 1 4 7
2 7 6 3 8 1 2 9 8
3 8 2 2 4 6 1 6 1
1 5 2 6 4 8 4 6 4
9 3 3 9 9 1 3 7 8
4 1 4 8 5 5 3 2 5
8
8 4 7 2 1 7 3 2
2 2 8 7 6 3 5 6
8 8 1 7 5 8 1 5
2 8 5 1 7 3 1 2
4 1 3 6 6 3 7 8
4 2 3 6 1 5 5 2
4 7 4 3 7 4 6 3
6 6 5 1 5 4 8 4
2
1 ...

output:

36
1 7 2 9 
1 1 3 6 
1 3 4 7 
1 6 5 2 
1 8 6 5 
1 5 7 8 
1 2 8 5 
1 4 9 4 
2 3 3 9 
2 6 4 9 
2 2 5 4 
2 5 6 8 
2 7 7 6 
2 1 8 6 
2 8 9 9 
3 2 4 6 
3 8 5 7 
3 4 6 2 
3 3 7 4 
3 7 8 4 
3 5 9 6 
4 4 5 6 
4 1 6 6 
4 3 7 9 
4 8 8 1 
4 2 9 5 
5 8 6 1 
5 9 7 2 
5 3 8 9 
5 5 9 3 
6 4 7 3 
6 3 8 7 
6 7 9 1 
...

result:

ok your solution is correct.

Test #16:

score: 0
Accepted
time: 7ms
memory: 7236kb

input:

9
8
8 7 6 6 2 2 6 2
5 1 6 5 5 4 1 2
5 3 8 1 2 2 4 3
5 4 7 8 7 1 7 1
6 4 8 4 1 6 8 3
3 3 1 8 3 5 4 3
7 6 5 2 7 3 6 8
8 4 7 2 1 7 5 4
6
3 3 6 2 5 2
5 5 4 4 6 1
6 4 1 3 2 4
3 5 3 6 3 1
4 2 2 1 6 5
1 6 5 4 1 2
118
1 18 1 1 1 1 1 1 4 1 115 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 18 62 1 1 1 1 1 1 1...

output:

28
1 8 2 8 
1 6 3 8 
1 7 4 2 
1 5 5 6 
1 2 6 6 
1 4 7 5 
1 3 8 5 
2 3 3 2 
2 5 4 1 
2 2 5 1 
2 4 6 7 
2 1 7 1 
2 6 8 1 
3 6 4 8 
3 7 5 4 
3 5 6 8 
3 4 7 8 
3 3 8 6 
4 7 5 2 
4 4 6 4 
4 5 7 6 
4 3 8 3 
5 5 6 5 
5 3 7 7 
5 8 8 7 
6 1 7 2 
6 3 8 8 
7 3 8 2 
15
1 4 2 6 
1 3 3 6 
1 2 4 5 
1 1 5 6 
1 5 6 ...

result:

ok your solution is correct.

Test #17:

score: 0
Accepted
time: 140ms
memory: 10644kb

input:

1
200
10 98 86 3 124 117 19 6 74 143 48 196 32 33 15 5 23 56 138 65 150 46 125 157 43 162 48 141 161 93 179 175 163 1 144 183 105 65 158 195 102 112 69 194 142 177 182 135 60 77 140 117 47 171 5 157 14 115 17 163 130 55 134 74 10 108 117 181 75 154 14 138 106 60 127 25 162 196 172 156 66 41 20 127 1...

output:

19900
1 183 2 141 
1 8 3 170 
1 4 4 197 
1 78 5 76 
1 34 6 174 
1 65 7 143 
1 1 8 166 
1 104 9 188 
1 44 10 162 
1 12 11 189 
1 112 12 181 
1 55 13 106 
1 16 14 95 
1 180 15 110 
1 186 16 197 
1 94 17 178 
1 40 18 12 
1 175 19 199 
1 15 20 2 
1 194 21 60 
1 174 22 70 
1 187 23 103 
1 36 24 16 
1 99 ...

result:

ok your solution is correct.

Test #18:

score: 0
Accepted
time: 128ms
memory: 10932kb

input:

1
200
42 73 47 35 98 195 170 82 124 40 112 112 80 136 155 167 74 76 68 175 89 120 162 78 36 65 58 93 75 42 173 84 148 52 29 59 10 32 34 87 101 176 48 36 139 197 170 149 77 157 122 68 96 95 190 130 97 125 36 4 107 61 174 121 48 166 103 182 96 96 128 200 44 188 32 1 196 61 141 123 153 18 181 199 101 5...

output:

19900
1 132 2 191 
1 60 3 27 
1 181 4 57 
1 180 5 94 
1 92 6 78 
1 76 7 143 
1 46 8 162 
1 55 9 153 
1 183 10 106 
1 170 11 105 
1 143 12 170 
1 152 13 108 
1 72 14 181 
1 126 15 175 
1 186 16 4 
1 157 17 154 
1 185 18 49 
1 175 19 89 
1 159 20 130 
1 77 21 127 
1 84 22 58 
1 164 23 98 
1 91 24 161 ...

result:

ok your solution is correct.

Test #19:

score: 0
Accepted
time: 131ms
memory: 11328kb

input:

1
200
50 94 96 46 14 72 8 114 112 20 65 181 26 198 1 48 129 163 61 44 64 53 39 18 119 183 32 138 194 35 14 24 117 21 136 59 136 63 55 177 106 7 192 127 139 41 171 171 143 62 74 134 110 125 74 197 23 173 159 165 178 70 99 68 42 5 68 172 179 34 38 47 196 194 115 83 20 128 156 79 4 90 151 133 107 164 8...

output:

19900
1 15 2 43 
1 7 3 139 
1 172 4 193 
1 147 5 81 
1 129 6 117 
1 159 7 29 
1 109 8 167 
1 101 9 13 
1 42 10 110 
1 153 11 83 
1 66 12 16 
1 200 13 129 
1 112 14 157 
1 81 15 94 
1 14 16 193 
1 177 17 195 
1 31 18 63 
1 24 19 68 
1 5 20 156 
1 182 21 108 
1 119 22 16 
1 96 23 83 
1 166 24 175 
1 7...

result:

ok your solution is correct.

Test #20:

score: 0
Accepted
time: 44ms
memory: 11112kb

input:

1
200
1 1 1 1 1 1 1 1 169 1 1 1 1 9 1 1 1 1 1 1 1 1 1 1 99 1 196 90 1 1 1 1 1 83 174 1 1 1 83 1 1 73 1 59 1 153 1 1 1 1 1 1 1 1 1 1 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 175 1 1 1 1 1 1 1 63 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 102 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 37 1 1...

output:

19900
1 198 2 200 
1 197 3 199 
1 196 4 200 
1 195 5 199 
1 194 6 199 
1 193 7 200 
1 191 8 199 
1 190 9 200 
1 189 10 200 
1 187 11 200 
1 186 12 200 
1 185 13 200 
1 184 14 200 
1 183 15 199 
1 182 16 200 
1 181 17 200 
1 180 18 200 
1 178 19 200 
1 177 20 200 
1 175 21 200 
1 174 22 200 
1 173 23...

result:

ok your solution is correct.

Extra Test:

score: 0
Extra Test Passed