QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#428968#8759. 小班课do_while_trueAC ✓434ms16800kbC++203.6kb2024-06-01 23:34:002024-06-01 23:34:00

Judging History

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

  • [2024-06-01 23:34:00]
  • 评测
  • 测评结果:AC
  • 用时:434ms
  • 内存:16800kb
  • [2024-06-01 23:34:00]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<assert.h>
#include<ctime>
#define pb emplace_back
#define mp std::make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
	r=0;bool w=0;char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
	while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
	return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x, T2& ...y){ read(x); read(y...); }
const int N=1010;
const int inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;
int S,T,tot;
int head[N],cur[N],lst[N],pre[N],vis[N],ent=1;
ll flow[N],dis[N];
struct Edge{
	int to,nxt;
	ll fl,co;
}e[1000010];
inline void adde(int x,int y,ll w,ll c){
	e[++ent]={y,head[x],w,c};head[x]=ent;
	e[++ent]={x,head[y],0,-c};head[y]=ent;
}
int ok[N];
bool SPFA(){
	for(int i=1;i<=tot;i++)lst[i]=pre[i]=ok[i]=0,dis[i]=flow[i]=INF,cur[i]=head[i];
	queue<int>q;
	q.push(S);dis[S]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		vis[x]=0;
		for(int i=head[x];i;i=e[i].nxt){
			int v=e[i].to;
			if(dis[v]>dis[x]+e[i].co&&e[i].fl){
				dis[v]=dis[x]+e[i].co;
				pre[v]=x;lst[v]=i;
				flow[v]=min(flow[x],e[i].fl);
				if(!vis[v]){
					q.push(v);
					vis[v]=1;
				}
			}
		}
	}
	return pre[T]>0;
}
int dfs(int x,int flow){
	if(x==T)return flow;
	int flo=0;
	ok[x]=1;
	for(int i=cur[x];i&&flo<flow;i=e[i].nxt){
		cur[x]=i;
		int v=e[i].to,w=e[i].fl;
		if(!ok[v] && dis[v]==dis[x]+e[i].co&&w){
			int fl=dfs(v,min(flow-flo,w));
			flo+=fl;e[i].fl-=fl;
			e[i^1].fl+=fl;
		}
	}
	ok[x]=0;
	return flo;
}
void MCMF(){
	ll mxfl=0;
	while(SPFA()){
		mxfl+=dfs(S,inf);
	}
	cout<<mxfl<<'\n';
}
int n,m,p[N],q[N],res[N],bo[N];
vi eg[N];
void solve(){
	ent=1;
	for(int i=1;i<=tot;i++)head[i]=lst[i]=pre[i]=vis[i]=flow[i]=dis[i]=0;
	tot=0;
	read(n,m);
	for(int i=1;i<=n;i++)p[i]=++tot;
	for(int i=1;i<=m;i++)q[i]=++tot;
	S=++tot;T=++tot;
	for(int i=1;i<=n;i++)adde(S,p[i],1,0);
	for(int i=1;i<=m;i++){
		int x;read(x);res[i]=x;
		adde(q[i],T,x,0);
	}
	for(int i=1;i<=n;i++){
		int k;read(k);
		vi().swap(eg[i]);
		for(int j=0;j<k;j++){
			int y;read(y);
			eg[i].pb(y);
			adde(p[i],q[y],1,j);
		}
	}
	MCMF();
	vpii vec;
	for(int x=1;x<=n;x++){
		int ok=0;
		for(int i=head[x];i;i=e[i].nxt){
			int v=e[i].to,fl=e[i].fl,co=e[i].co;
			if(!fl && v>=q[1] && v<=q[m]){
				ok=1;
				bo[x]=co;
			}
		}
		if(ok==0)bo[x]=-1;
	}
	vi ans;
	while(1){
		int ok=0;
		for(int i=1;i<=n;i++){
			int len=eg[i].size();
			for(int j=0;j<len;j++){
				if(res[eg[i][j]]==0)continue;
				else{
					if(j==bo[i]){
						--res[eg[i][j]];
						ans.pb(i);
						ok=1;
						bo[i]=-2;
					}
					break;
				}
			}
		}
		if(!ok)break;
	}
	for(int i=1;i<=n;i++)if(bo[i]==-1)ans.pb(i);
	for(int i:ans)cout<<i<<' ';
	cout<<'\n';
}
signed main(){
	// assert(freopen("data.in","r",stdin));
	int T;read(T);
	while(T--)solve();
    #ifdef do_while_true
		// cerr<<'\n'<<"Time:"<<clock()<<" ms"<<'\n';
	#endif
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct!

Test #2:

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

input:

250
2 1
2
1 1
1 1
1 1
1
0
2 2
1 1
1 1
2 2 1
2 2
0 2
2 1 2
1 2
1 1
1
1 1
1 2
1 0
0
1 2
1 0
0
2 1
2
1 1
0
1 2
1 0
0
2 1
2
1 1
1 1
1 1
1
1 1
1 2
1 0
1 2
2 2
2 0
1 1
1 2
1 1
1
0
1 1
1
0
1 2
0 1
1 1
2 2
1 1
1 1
2 1 2
2 2
1 1
2 2 1
2 2 1
1 2
0 1
1 2
2 1
2
1 1
0
2 2
2 0
1 1
1 2
1 1
1
1 1
2 1
2
0
1 1
1 1
1
...

output:

2
1 2 
0
1 
2
1 2 
2
1 2 
1
1 
0
1 
0
1 
1
1 2 
0
1 
2
1 2 
1
1 
0
1 
1
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
3
3 4 1 2 5 
3
1 2 4 3 5 
3
1 3 2 4 5 
2
1 3 2 4 5 
3
1 4 5 2 3 
1
1 2 3 4 5 
3
2 3 5 1 4 
1
4 1 2 3 5 
2
3 4 1 2 5 
2
1 4 2 3 5 
2...

result:

ok Correct!

Test #6:

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

input:

10
45 47
3 0 2 0 1 1 1 0 2 0 1 0 0 3 0 0 0 4 0 1 0 0 1 2 1 1 1 0 1 1 1 0 0 0 0 1 0 0 0 1 2 4 1 2 1 2 3
7 1 37 21 3 13 43 22
0
10 23 46 22 40 12 19 47 27 16 42
4 29 19 45 35
10 6 26 2 43 41 7 9 16 42 44
5 39 40 34 46 14
3 34 3 38
8 10 5 38 23 19 37 9 34
0
5 31 29 15 13 35
3 40 4 28
1 7
6 29 12 9 35 2...

output:

33
1 7 11 12 14 15 16 17 19 21 25 29 30 31 37 38 39 40 42 43 44 5 6 8 10 13 24 35 36 3 4 18 34 2 9 20 22 23 26 27 28 32 33 41 45 
39
3 10 12 14 15 16 17 18 19 20 25 28 29 30 31 32 33 35 38 40 42 43 44 45 2 7 9 11 21 24 26 34 36 5 6 23 39 41 1 4 8 13 22 27 37 
36
1 3 4 8 10 16 17 20 21 23 25 27 28 29...

result:

ok Correct!

Test #7:

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

input:

1
499 497
1 2 0 2 0 1 0 0 0 2 1 2 0 3 1 2 0 0 0 1 0 1 0 2 1 0 1 0 1 1 1 2 0 1 0 1 0 2 2 3 1 1 2 1 0 0 1 0 2 3 0 1 0 0 2 0 1 2 1 0 0 1 2 0 0 2 0 2 0 1 0 1 0 0 1 0 0 1 1 1 1 1 0 0 0 1 2 3 0 0 0 4 2 2 1 2 2 0 1 0 1 0 2 0 1 0 2 0 0 1 1 1 3 2 0 2 2 2 0 1 1 1 1 1 0 1 0 1 1 1 1 1 2 0 0 1 0 2 1 2 1 2 1 0 1 ...

output:

482
1 2 3 4 5 6 8 10 12 16 17 18 22 27 28 30 31 33 34 35 38 39 40 41 42 43 47 48 49 51 53 55 56 58 59 60 61 63 64 66 69 70 73 75 76 81 82 86 87 88 89 90 91 92 95 96 101 104 106 108 110 111 112 113 117 118 119 120 122 123 124 125 126 134 135 136 138 139 141 142 143 144 145 147 148 149 150 153 155 156...

result:

ok Correct!

Test #8:

score: 0
Accepted
time: 434ms
memory: 16800kb

input:

1
498 499
0 1 1 0 1 0 1 0 0 0 0 2 0 3 1 2 4 0 1 0 1 1 0 0 0 1 1 0 0 2 2 0 1 1 1 0 4 1 1 2 1 0 0 1 2 0 1 2 1 0 1 2 0 2 1 2 2 0 2 2 0 1 0 2 0 0 3 0 1 1 1 1 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 2 1 1 0 1 0 1 0 0 0 1 1 2 0 1 0 2 1 1 2 2 0 0 0 0 2 0 2 1 0 1 0 2 0 1 3 1 1 1 0 1 3 0 1 0 1 0 0 1 3 2 3 2 1 1 0 2 ...

output:

498
1 2 3 5 7 8 12 15 16 18 19 20 24 26 28 29 33 34 35 36 37 39 40 41 44 45 46 47 50 52 53 55 56 57 59 66 68 69 72 73 74 77 78 79 80 82 83 85 86 88 90 92 96 98 101 106 107 108 110 111 112 113 114 116 117 118 120 123 124 125 126 127 129 130 132 133 134 135 136 137 139 140 141 142 146 147 148 149 150 ...

result:

ok Correct!

Test #9:

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

input:

5
99 96
2 0 0 1 1 2 1 0 1 1 1 0 0 0 1 0 1 1 2 1 1 1 1 1 0 1 2 4 0 0 0 2 2 1 1 1 1 1 0 2 0 0 0 1 1 3 0 1 0 0 1 2 1 4 1 2 1 0 1 0 0 2 0 0 0 2 3 2 1 0 1 2 2 0 1 1 0 0 1 0 0 1 2 1 3 1 3 1 3 0 3 0 0 2 2 2
2 14 58
1 55
2 53 69
0
0
1 76
2 23 38
1 41
2 74 54
0
0
2 83 91
0
0
0
1 48
0
0
1 96
2 76 52
1 17
2 51...

output:

48
2 3 6 7 9 12 16 19 20 21 22 24 25 26 30 34 35 38 39 40 44 45 46 53 57 60 62 65 69 71 72 73 74 77 78 82 87 88 92 93 94 95 97 99 23 42 56 59 1 4 5 8 10 11 13 14 15 17 18 27 28 29 31 32 33 36 37 41 43 47 48 49 50 51 52 54 55 58 61 63 64 66 67 68 70 75 76 79 80 81 83 84 85 86 89 90 91 96 98 
44
7 8 1...

result:

ok Correct!

Test #10:

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

input:

5
99 97
0 2 4 0 0 2 0 1 1 1 0 1 0 3 0 1 1 1 1 0 0 1 0 0 1 2 0 0 1 3 1 2 0 2 1 1 1 3 3 1 2 1 0 1 0 1 0 2 0 0 0 0 1 2 3 1 1 1 0 1 0 1 0 0 1 2 1 2 1 1 1 2 2 3 1 1 0 0 1 1 0 0 1 1 2 1 2 2 0 1 1 1 2 0 1 3 1
2 56 63
2 52 45
4 26 56 80 10
2 27 19
1 81
2 38 64
1 83
1 8
3 14 81 60
3 63 28 15
5 59 33 80 88 56...

output:

72
1 3 6 7 8 9 11 12 13 14 16 17 20 22 23 24 25 28 29 30 32 33 35 37 39 40 41 44 45 46 47 48 49 53 55 57 58 62 63 64 65 66 68 70 71 72 73 76 77 78 79 81 82 83 85 87 90 91 94 95 96 97 98 99 18 27 34 42 52 54 59 60 2 4 5 10 15 19 21 26 31 36 38 43 50 51 56 61 67 69 74 75 80 84 86 88 89 92 93 
67
2 3 7...

result:

ok Correct!

Test #11:

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

input:

5
99 98
4 0 1 1 3 2 0 1 4 0 1 1 2 2 1 2 0 0 1 2 1 2 0 1 1 1 2 0 2 0 0 3 0 2 0 0 1 1 1 0 1 1 1 2 0 1 1 0 1 1 1 0 0 1 0 0 2 1 2 3 3 0 0 0 0 0 1 2 1 1 0 3 0 0 0 1 2 0 0 0 0 1 0 2 2 1 2 1 0 1 0 0 1 1 2 3 3 0
5 72 78 90 7 60
6 69 37 10 41 4 59
10 61 85 79 5 7 58 3 55 1 50
6 59 24 30 26 77 21
2 29 21
10 7...

output:

85
1 3 4 5 8 11 12 15 19 20 21 23 24 25 27 29 30 32 35 37 38 39 40 41 42 47 50 51 53 54 55 59 62 64 65 66 67 68 69 70 71 72 73 74 76 77 78 79 81 82 83 84 85 86 89 90 91 93 94 96 97 98 99 10 26 33 34 43 44 46 49 57 58 63 75 87 95 2 16 28 31 80 6 14 60 7 9 13 17 18 22 36 45 48 52 56 61 88 92 
87
2 3 5...

result:

ok Correct!

Test #12:

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

input:

5
97 100
1 1 1 0 0 1 0 1 1 2 0 1 2 0 1 0 2 3 0 1 0 1 0 1 0 0 1 0 1 2 0 3 2 2 1 0 1 1 2 3 3 1 0 2 1 1 1 2 2 2 0 2 0 3 1 2 2 2 0 1 0 1 1 0 2 0 0 0 0 3 1 0 0 1 0 1 1 0 0 1 1 2 1 2 0 0 1 2 0 1 1 0 2 0 0 1 0 0 2 2
48 80 1 66 89 71 73 40 2 50 99 68 91 31 76 25 67 94 37 6 88 86 28 22 43 62 21 16 17 39 70 1...

output:

94
2 4 5 6 8 9 10 12 14 15 16 19 20 23 24 25 26 27 29 30 31 33 34 36 37 39 40 41 42 43 44 45 47 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 69 70 71 72 73 77 78 79 80 82 83 84 85 86 87 88 89 90 91 92 93 94 96 97 1 3 7 11 13 17 18 21 28 32 35 38 48 59 61 75 76 81 22 74 46 68 95 
94
2 6 7 9 10 ...

result:

ok Correct!

Test #13:

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

input:

5
96 96
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 72 44
0
0
1 75
0
2 48 35
1 29
1 55
2 75 32
1 95
0
2 87 85
1 69
1 6
2 48 6
1 77
1 67
0
0
1 75
2 59 ...

output:

59
8 12 13 15 16 17 20 21 23 24 25 29 31 32 34 35 36 39 41 45 47 48 49 51 55 56 58 60 61 64 65 67 68 70 71 73 74 75 78 79 80 81 82 83 85 86 87 88 89 90 91 96 6 9 27 44 46 62 1 2 3 4 5 7 10 11 14 18 19 22 26 28 30 33 37 38 40 42 43 50 52 53 54 57 59 63 66 69 72 76 77 84 92 93 94 95 
54
4 7 11 14 16 1...

result:

ok Correct!

Test #14:

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

input:

1
499 497
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

287
1 2 3 6 7 8 10 15 21 23 25 26 27 28 29 31 32 34 37 39 40 41 43 47 48 53 55 57 58 60 61 67 68 69 75 77 81 82 84 85 87 89 91 92 96 99 106 107 108 111 114 115 116 119 120 122 123 125 126 134 137 140 141 145 146 147 148 150 152 154 156 159 161 162 164 166 167 169 170 172 174 176 178 179 183 185 186 ...

result:

ok Correct!

Test #15:

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

input:

10
50 49
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 43
0
0
2 25 28
0
0
2 28 14
0
2 8 38
1 1
0
1 6
1 41
0
2 40 47
2 8 34
2 26 41
2 31 28
1 5
0
2 33 45
0
2 14 43
0
2 39 34
1 32
1 6
1 15
1 17
0
0
2 9 6
2 37 1
0
2 13 20
0
2 4 41
2 31 5
0
2 44 14
1...

output:

30
1 4 7 10 13 15 16 17 19 23 25 27 29 32 33 35 37 38 40 41 43 44 45 46 47 48 49 50 9 21 2 3 5 6 8 11 12 14 18 20 22 24 26 28 30 31 34 36 39 42 
27
3 5 6 9 10 17 20 21 24 25 27 35 38 39 41 43 44 45 48 49 50 14 29 33 34 40 16 1 2 4 7 8 11 12 13 15 18 19 22 23 26 28 30 31 32 36 37 42 46 47 
25
1 2 3 7...

result:

ok Correct!

Test #16:

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

input:

10
50 49
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 32
0
0
2 47 41
1 10
3 33 18 13
1 43
1 49
1 39
0
0
3 16 27 31
0
0
2 30 25
3 23 16 37
3 18 1 46
2 8 9
3 32 33 10
3 24 14 31
3 31 11 2
2 8 36
1 44
1 9
0
2 39 27
1 14
1 6
3 47 12 10
1 14
1 10
0
1...

output:

32
7 8 9 12 15 16 20 22 23 24 26 28 29 30 31 33 36 38 39 40 42 44 45 46 47 48 49 4 17 19 21 6 1 2 3 5 10 11 13 14 18 25 27 32 34 35 37 41 43 50 
31
1 5 6 11 16 17 23 25 26 27 28 29 31 32 33 34 36 39 40 41 42 46 47 48 49 2 3 4 21 38 43 7 8 9 10 12 13 14 15 18 19 20 22 24 30 35 37 44 45 50 
35
1 2 3 6...

result:

ok Correct!

Test #17:

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

input:

1
495 495
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

344
1 2 4 6 10 16 18 19 20 23 24 25 28 41 42 45 48 50 51 54 59 68 70 71 74 77 78 79 82 90 91 94 95 96 97 102 103 104 107 109 111 113 114 115 116 120 121 122 123 125 127 129 132 133 136 139 144 145 146 148 150 153 155 156 158 160 161 162 168 169 171 173 174 175 178 179 180 181 182 184 185 187 190 191...

result:

ok Correct!

Test #18:

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

input:

250
1 2
1 0
2 1 2
2 2
0 2
1 1
1 1
2 2
1 1
2 1 2
2 1 2
1 1
1
0
2 2
0 2
2 1 2
0
2 1
2
1 1
0
2 2
0 2
1 1
2 1 2
2 1
2
0
0
1 2
0 1
2 1 2
1 1
1
1 1
2 1
2
0
1 1
2 2
1 1
2 1 2
1 1
1 1
1
1 1
2 1
2
0
1 1
1 2
0 1
2 1 2
1 2
0 1
0
1 2
0 1
1 1
2 2
1 1
1 1
2 1 2
2 1
2
1 1
1 1
1 2
1 0
2 1 2
1 2
0 1
2 1 2
1 2
1 0
2 ...

output:

1
1 
0
1 2 
2
2 1 
0
1 
1
1 2 
1
1 2 
1
2 1 
0
1 2 
1
1 
1
1 
1
2 1 
2
2 1 
1
1 
1
2 1 
1
1 
0
1 
0
1 
2
1 2 
2
1 2 
1
1 
1
1 
1
1 
2
1 2 
0
1 2 
2
1 2 
1
1 
1
1 2 
0
1 
1
1 
1
1 
1
1 2 
2
1 2 
1
2 1 
1
1 
1
2 1 
0
1 
1
1 
2
1 2 
1
1 
1
2 1 
1
2 1 
0
1 2 
0
1 
0
1 2 
1
1 
1
2 1 
0
1 2 
1
1 2 
1
1 
0...

result:

ok Correct!

Test #19:

score: 0
Accepted
time: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0 1 0 2 2 0 0 4 1 3 3 3
5 3 10 12 16 18
5 2 16 36 21 39
9 19 23 5 31 32 12 15 34 40
0
5 5 19 21 24 30
3 6 8 16
6 15 17 26 2 14 7
1 3
2 14 15
3 16 21 23
6 3 4 17 19 21 22
1 7
7 2 11 28 10 13 31 6
0
6 13 33 43 47 14 1
4...

output:

29
6 7 9 10 11 15 16 26 28 30 34 38 41 42 45 46 49 2 13 17 18 22 32 33 39 3 5 20 36 1 4 8 12 14 19 21 23 24 25 27 29 31 35 37 40 43 44 47 48 
22
7 9 12 13 21 22 24 27 28 29 38 41 42 45 46 47 2 23 25 32 36 48 1 3 4 5 6 8 10 11 14 15 16 17 18 19 20 26 30 31 33 34 35 37 39 40 43 44 49 
28
6 7 16 28 31 ...

result:

ok Correct!

Test #23:

score: 0
Accepted
time: 13ms
memory: 4344kb

input:

1
498 500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 2 1 0 1 0 0 2 0 1 0 0 1 1 0 0 0 0 0 2 0 0 1 0 1 0 0 0 0 0 2 1 2 0 1 0 0 1 1 0 1 ...

output:

464
5 6 7 10 12 16 17 18 21 24 26 27 30 33 39 40 43 45 46 48 49 52 54 55 56 58 60 73 74 78 79 80 81 83 91 93 94 100 107 109 110 115 116 118 129 135 145 146 151 154 160 161 162 165 171 175 177 178 182 184 189 190 196 197 198 205 208 212 216 218 223 225 226 227 229 231 232 237 238 241 245 246 251 253 ...

result:

ok Correct!

Test #24:

score: 0
Accepted
time: 363ms
memory: 10028kb

input:

1
497 496
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 1 0 2 1 0 0 0 0 0 0 0 1 1 0 1 0 1 2 1 2 0 1 0 0 1 2 0 1 1 1 0 0 0 0 2 1 1 1 0 0 1 ...

output:

496
10 16 21 28 33 43 53 58 60 64 78 90 96 97 100 102 106 109 110 119 131 132 137 141 142 143 149 154 155 162 170 174 178 185 186 189 191 194 198 199 211 212 213 215 218 220 222 225 227 232 233 235 240 241 242 246 248 250 252 256 261 262 268 269 270 272 275 276 280 284 285 289 293 298 300 303 308 30...

result:

ok Correct!

Test #25:

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

input:

5
100 100
0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 2 0 1 0 0 1 1 1 1 0 2 1 0 0 1 2 1 0 1 1 1 1 0 1 1 2 5 1 0 1 2 0 2 0 3 1 1 1 2 3 2 1 1 1 2 4 2 1 4 1 2 1 0 3 3 1 3 0 0 3 1 0 0 0 3 4 2
1 35
0
1 8
1 35
0
0
1 10
2 15 19
2 1 3
2 6 61
0
0
0
0
2 14 20
2 4 80
0
0
0
1 6
0
1 13
1 4
...

output:

19
7 10 16 27 37 39 43 48 57 59 66 73 76 79 83 84 92 98 54 1 2 3 4 5 6 8 9 11 12 13 14 15 17 18 19 20 21 22 23 24 25 26 28 29 30 31 32 33 34 35 36 38 40 41 42 44 45 46 47 49 50 51 52 53 55 56 58 60 61 62 63 64 65 67 68 69 70 71 72 74 75 77 78 80 81 82 85 86 87 88 89 90 91 93 94 95 96 97 99 100 
26
3...

result:

ok Correct!

Test #26:

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

input:

5
95 99
0 0 1 0 0 0 0 0 1 1 0 0 0 2 1 0 0 0 1 0 1 0 0 0 1 2 0 0 1 1 2 0 0 0 1 0 0 1 1 1 0 1 0 1 1 0 1 1 1 2 2 0 0 0 1 0 1 1 1 4 3 0 3 1 2 1 0 1 0 1 5 0 1 1 0 3 0 3 1 2 2 4 0 0 0 1 1 1 2 3 1 0 2 4 0 1 1 4 3
0
1 5
3 31 50 70
1 21
5 14 26 31 2 6
5 7 41 19 45 30
3 1 6 40
0
2 16 19
4 5 6 9 25
0
0
5 17 47...

output:

41
5 15 17 18 19 28 30 36 42 43 44 45 47 49 51 54 57 59 61 63 69 70 71 73 75 78 82 83 84 85 87 88 89 92 3 13 16 41 62 65 79 1 2 4 6 7 8 9 10 11 12 14 20 21 22 23 24 25 26 27 29 31 32 33 34 35 37 38 39 40 46 48 50 52 53 55 56 58 60 64 66 67 68 72 74 76 77 80 81 86 90 91 93 94 95 
37
1 5 10 16 19 30 3...

result:

ok Correct!

Test #27:

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

input:

5
97 97
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 1 0 0 1 1 2 0 0 1 2 1 0 0 1 2 2 1 0 2 0 1 0 0 3 0 2 3 0 2 1 1 1 1 0 1 1 2 4 1 0 2 1 0 1 2 1 2 2 2 1 2 5 2 0 1 0 3 1 3 1 0 1 2 0 0 2 4 2 2 1 2 1 3 0
0
5 14 16 33 41 9
7 12 28 16 32 45 46 71
10 15 63 65 17 66 18 81 45 8 68
6 8 35 12 54 21 63
0
0
0
...

output:

67
2 4 5 14 16 22 26 38 42 43 45 49 52 54 57 59 62 65 66 70 71 73 75 80 83 86 92 94 96 97 10 13 25 41 47 48 50 51 55 56 58 60 63 67 69 72 77 78 87 89 93 95 3 19 21 24 29 31 34 36 53 64 81 20 23 27 84 1 6 7 8 9 11 12 15 17 18 28 30 32 33 35 37 39 40 44 46 61 68 74 76 79 82 85 88 90 91 
62
15 16 20 24...

result:

ok Correct!

Test #28:

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

input:

5
95 95
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 1 1 0 1 0 1 1 1 0 0 2 1 0 0 1 1 0 0 1 0 1 0 0 3 0 2 1 1 5 0 0 0 4 3 0 2 1 0 3 2 2 1 2 1 6 1 3 4 2 1 2 2 3 0 2 0 2 1 1 2 2 1 0 2 1 0 0 1 2 3
16 2 9 23 36 52 58 31 65 66 71 72 17 75 24 44 27
28 4 2 32 38 45 21 52 61 94 55 46 79 92 1 11 65 73 95...

output:

89
3 14 16 17 25 27 28 30 32 35 37 38 40 41 42 44 53 54 59 60 64 68 71 72 73 77 82 83 84 85 91 94 95 1 6 9 10 15 18 21 23 26 29 31 33 34 36 43 45 46 48 49 55 56 57 61 63 65 66 70 74 75 76 79 80 81 87 92 93 2 4 7 11 13 19 20 22 39 47 50 51 52 58 67 69 86 88 89 78 5 8 12 24 62 90 
89
4 5 6 7 14 15 19 ...

result:

ok Correct!

Test #29:

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

input:

1
498 500
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 2 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 1 1 2 0 0 1 0 0 0 0 0 1 0 0 2 0 1 1 1 0 0 1 0 2 0 0 1 1 0 0 2 0 0 0 0 0 3 1 0 2 0 1 3 0 0 0 ...

output:

108
12 14 29 33 42 48 51 54 57 58 60 86 94 99 110 125 127 133 137 139 144 149 153 159 161 173 187 188 192 197 199 212 228 231 237 240 243 247 251 255 260 277 282 286 288 291 297 298 300 307 311 319 323 329 330 331 347 348 354 360 361 365 372 374 382 392 393 394 395 397 401 405 407 409 417 427 429 43...

result:

ok Correct!

Test #30:

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

input:

1
500 498
2 0 0 1 1 1 0 0 0 0 1 1 2 2 2 0 1 0 0 0 1 1 1 0 1 1 2 2 2 1 1 0 4 3 1 1 1 1 0 3 0 3 3 1 2 1 0 2 3 2 0 2 0 0 0 1 1 1 0 2 4 1 0 1 1 1 1 3 1 0 0 1 1 2 2 4 1 1 1 0 0 2 2 1 2 1 1 1 0 0 2 0 0 1 0 0 1 1 1 1 0 1 0 0 1 2 1 1 1 2 2 4 2 0 0 0 0 1 1 0 1 4 1 3 0 2 0 3 0 1 1 1 0 4 0 1 1 3 2 0 0 1 0 1 1 ...

output:

258
1 4 9 12 18 24 28 37 38 52 60 61 62 66 68 73 75 76 79 80 91 94 99 108 110 114 118 122 130 131 133 136 138 146 147 148 150 152 154 155 156 157 165 166 169 174 176 180 183 184 185 188 189 190 191 192 193 194 195 204 205 207 213 215 216 218 220 225 226 228 231 238 242 243 244 247 249 250 252 253 25...

result:

ok Correct!

Test #31:

score: 0
Accepted
time: 51ms
memory: 11816kb

input:

1
496 498
0 0 0 0 2 0 0 1 0 1 1 0 2 3 1 1 2 0 3 2 2 0 2 1 2 0 1 1 1 0 1 2 0 0 0 0 5 1 1 0 2 1 0 0 1 0 0 2 0 3 0 0 3 1 0 3 0 1 1 2 1 2 0 2 0 2 1 0 3 0 1 0 1 1 2 0 1 0 0 1 2 1 2 0 1 0 1 1 1 0 3 3 3 2 0 1 2 1 1 3 1 1 0 0 3 0 1 0 0 0 0 1 3 1 0 1 1 2 1 0 1 2 0 2 0 1 1 1 2 2 0 0 1 2 1 1 1 2 1 3 1 1 1 0 0 ...

output:

248
1 4 8 9 13 14 18 23 28 30 31 32 35 42 43 44 45 46 47 49 50 51 52 54 58 60 66 71 73 78 80 83 91 94 97 99 100 101 102 103 106 111 114 117 119 123 125 127 130 136 143 150 159 169 173 175 180 183 186 188 189 192 193 194 197 199 200 207 208 211 213 215 221 222 225 226 227 228 236 238 241 242 246 248 ...

result:

ok Correct!

Test #32:

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

input:

10
49 50
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1
0
0
1 4
0
1 7
2 8 7
2 9 8
0
1 10
1 12
2 13 12
0
0
1 16
2 16 17
0
1 19
0
1 20
1 21
1 23
2 24 23
2 25 24
1 26
1 27
1 27
1 28
0
2 31 30
1 32
0
1 33
1 34
2 35 36
1 37
2 38 37
1 38
1 40
2 41 4...

output:

35
1 4 6 7 8 10 11 12 15 16 18 20 21 22 23 24 25 27 28 30 31 33 34 35 36 38 39 40 41 43 44 45 46 48 49 2 3 5 9 13 14 17 19 26 29 32 37 42 47 
31
1 7 9 11 12 13 14 16 17 18 20 21 23 24 27 28 29 30 32 34 35 36 37 38 40 42 43 45 46 47 49 2 3 4 5 6 8 10 15 19 22 25 26 31 33 39 41 44 48 
30
1 2 4 6 8 9 1...

result:

ok Correct!

Test #33:

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

input:

5
99 99
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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
0
0
2 5 4
1 5
1 7
0
1 9
1 10
0
2 12 11
1 12
1 14
1 14
2 15 16
1 17
0
1 19
1 19
1 21
2 21 2...

output:

60
1 5 6 8 9 12 14 15 16 19 21 22 23 25 26 27 33 34 36 38 40 41 43 44 45 50 51 53 55 56 57 58 60 62 67 68 69 70 71 73 75 76 77 81 84 85 87 88 91 93 94 95 96 97 99 4 11 32 66 31 2 3 7 10 13 17 18 20 24 28 29 30 35 37 39 42 46 47 48 49 52 54 59 61 63 64 65 72 74 78 79 80 82 83 86 89 90 92 98 
63
1 2 3...

result:

ok Correct!

Test #34:

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

input:

1
496 500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

325
1 2 3 4 6 7 9 11 12 13 14 16 18 23 24 26 27 28 29 30 31 32 35 36 38 40 42 43 44 45 47 49 50 53 54 55 57 58 60 62 63 64 65 66 68 69 70 71 73 75 76 77 78 82 84 85 88 90 91 92 93 95 97 98 99 101 103 104 105 107 108 109 112 113 114 115 116 117 118 119 120 121 122 125 126 127 129 131 132 134 135 137 ...

result:

ok Correct!

Test #35:

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

input:

10
46 47
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 4
1 5
2 5 6
2 6 5
3 8 6 7
0
1 8
1 10
0
2 11 13
2 14 13
2 14 13
3 15 14 16
2 16 15
1 18
1 18
0
1 20
1 21
1 21
0
2 23 24
1 26
2 27 26
1 27
1 29
1 29
1 31
1 30
1 32
1 32
1 33
2 35 36
2 35 37
1...

output:

34
2 4 5 8 9 11 13 14 15 17 19 21 23 24 26 28 29 30 32 33 34 35 36 40 41 42 43 44 45 46 6 12 39 37 1 3 7 10 16 18 20 22 25 27 31 38 
36
2 3 6 7 8 9 13 14 15 16 17 18 21 22 25 27 28 29 31 33 34 35 36 37 38 41 42 44 45 46 47 5 12 30 40 10 1 4 11 19 20 23 24 26 32 39 43 48 
39
1 5 6 8 9 10 11 12 13 14 ...

result:

ok Correct!

Test #36:

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

input:

5
99 99
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 1 3 2
2 4 3
2 4 3
0
2 6 7
1 6
3 8 7 9
2 10 9
1 11
3 12 11 10
3 13 12 11
1 12
2 13 14
0
1 15
...

output:

75
3 6 7 9 11 12 13 15 16 18 20 22 23 24 27 30 32 34 37 38 39 41 42 44 45 46 47 48 50 54 55 56 58 59 60 62 63 64 66 67 68 70 72 73 74 75 77 80 82 84 86 87 88 89 90 91 93 96 97 98 99 2 5 10 19 36 53 76 81 83 85 92 95 1 8 4 14 17 21 25 26 28 29 31 33 35 40 43 49 51 52 57 61 65 69 71 78 79 94 
75
1 3 4...

result:

ok Correct!

Test #37:

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

input:

1
495 497
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

383
2 4 6 8 10 11 12 13 14 18 20 21 22 23 25 26 27 30 31 32 33 34 36 37 39 42 43 45 47 48 51 52 53 54 55 57 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 78 79 80 81 82 83 84 86 87 89 90 92 94 95 96 97 98 99 102 103 106 107 108 109 111 112 114 115 117 119 121 122 123 124 125 128 130 132 134 ...

result:

ok Correct!

Test #38:

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

input:

10
45 49
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 3 5 2
0
2 6 5
3 4 5 8
3 9 6 8
3 7 8 10
1 8
3 8 11 10
2 12 10
3 13 12 10
3 14 15 12
3 14 13 12
3 15 17 13
2 15 18
3 19 17 18
4 16 17 19 20
3 18 21 20
1 18
2 19 21
3 21 20 23
3 23 21 25
1 22
3 ...

output:

43
1 3 4 5 6 7 8 10 12 14 15 16 18 19 22 25 26 27 30 31 33 34 35 37 40 41 42 43 44 45 11 13 17 20 21 23 24 28 32 36 39 9 38 2 29 
42
1 3 4 5 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 27 29 30 32 33 34 35 36 38 39 41 43 44 45 2 7 8 21 28 37 42 6 26 11 31 40 
44
1 2 3 5 7 8 9 11 12 15 16 18 19 23 25...

result:

ok Correct!

Test #39:

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

input:

5
95 98
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 5 1 3
1 6
3 5 4 7
2 7 8
1 7
3 7 10 6
3 9 11 8
4 10 8 9 11
3 9 10 12
1 12
3 12 14 15
1 16
4 14 ...

output:

90
1 2 3 6 8 9 10 11 12 15 16 17 19 20 21 22 23 24 25 26 28 29 30 31 32 33 35 36 37 38 40 41 43 47 50 51 52 53 54 56 58 60 63 64 67 68 70 71 72 73 74 75 77 80 81 87 89 90 91 92 93 94 95 4 7 13 14 18 34 39 45 48 49 55 61 66 69 76 79 82 83 85 86 42 44 46 59 62 65 84 5 27 57 78 88 
90
3 5 8 9 10 11 15 ...

result:

ok Correct!

Test #40:

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

input:

1
498 496
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

462
2 4 6 7 8 9 10 12 13 14 17 18 19 20 21 22 23 26 27 28 29 30 32 33 35 36 37 38 39 41 42 45 47 48 51 52 53 56 57 58 59 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 83 84 87 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 106 107 108 109 110 111 112 114 115 116 121 123 124 127 128 130 131...

result:

ok Correct!

Test #41:

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

input:

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

output:

47
2 3 4 5 6 8 10 11 13 14 15 17 19 20 21 22 23 24 25 26 27 30 31 32 34 35 37 38 40 41 43 44 46 47 48 49 7 9 12 16 18 28 29 36 39 42 45 1 33 
48
2 3 5 7 9 10 11 12 13 15 16 17 19 20 21 22 23 24 25 26 28 29 30 31 32 33 34 36 37 38 39 42 44 46 47 4 6 14 18 27 35 40 43 45 48 8 41 1 
47
3 4 7 8 9 11 13 ...

result:

ok Correct!

Test #42:

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

input:

5
99 100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 9 7
5 2 9 8 11 7
6 5 8 4 9 3 11
6 9 8 13 10 12 4
6 5 6 12 14 9 11
2 10 14
8 12 15 8 9 14 ...

output:

99
4 6 7 8 9 14 15 16 18 19 20 22 23 25 26 29 30 31 33 34 36 37 39 40 41 42 43 44 46 48 49 50 53 55 56 57 58 59 62 64 65 66 68 69 70 71 72 74 75 76 77 80 82 83 84 85 86 87 89 90 91 95 96 97 98 1 2 3 5 10 12 13 17 21 24 28 32 35 38 45 47 52 61 63 67 81 88 92 93 94 99 11 27 51 54 60 73 78 79 
95
4 5 6...

result:

ok Correct!

Test #43:

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

input:

1
498 499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

497
1 3 4 5 8 10 11 12 13 16 17 19 20 21 22 23 24 26 27 30 33 35 36 37 40 41 44 45 46 47 48 51 52 53 54 55 56 57 59 62 63 64 65 69 70 73 74 75 76 77 78 80 81 82 83 84 87 88 89 90 91 97 98 99 100 102 103 104 105 106 107 114 117 118 120 124 125 126 127 130 131 132 135 136 141 143 144 145 146 147 148 1...

result:

ok Correct!