QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#104311#6382. LaLa and Spirit SummoningchenshiTL 3ms3144kbC++2.9kb2023-05-10 01:05:372023-05-10 01:05:59

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-10 01:05:59]
  • 评测
  • 测评结果:TL
  • 用时:3ms
  • 内存:3144kb
  • [2023-05-10 01:05:37]
  • 提交

answer

//https://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=2C454AA83DC52FE7B02496D6A56F913F?doi=10.1.1.49.8756&rep=rep1&type=pdf
#include<cstdio>
#include<vector>
#include<array>
#include<queue>
using namespace std;
int n,m;vector<int> u,v,c;
struct color{
	vector<int> flg,c;
	color(int m,vector<int> c_):flg(m),c(c_){}
	inline bool chk(int t){return !flg[c[t]];}
	inline void ins(int t){flg[c[t]]=1;}
	inline void clear(){flg.assign(m,0);}
};
struct rigidity{
	int asd;vector<int> u,v,col,lst,frmx,frmt;vector<array<int,2> > pebble;queue<int> qx,qy;
	rigidity(int n,int m,vector<int> u_,vector<int> v_):u(u_),v(v_),col(n),lst(n),frmx(m),frmt(m),pebble(n,{-1,-1}){}
	inline bool push(int x,int y,int t){
		if(pebble[x][t]<0) return true;
		++asd;lst[x]=-1;
		int id=pebble[x][t];
		if((x^u[id]^v[id])==y) return false;
		col[x]=col[y]=col[x^u[id]^v[id]]=asd;
		queue<int>().swap(qx);queue<int>().swap(qy);
		qx.push(x);qy.push(t);
		for(;!qx.empty();qx.pop(),qy.pop()){
			id=pebble[x=qx.front()][t=qy.front()];
			col[y=(x^u[id]^v[id])]=asd;lst[y]=id;
			for(int i=0;i<2;++i){
				if(pebble[y][i]<0){
					for(x=y,t=i;lst[x]>=0;x=y,t=i)
						id=lst[x],y=frmx[id],i=frmt[id],pebble[frmx[id]=x][frmt[id]=t]=id;
					pebble[x][t]=-1;
					return true;
				}
				id=pebble[y][i];
				if(col[y^u[id]^v[id]]^asd) col[y^u[id]^v[id]]=asd,qx.push(y),qy.push(i);
			}
		}
		return false;
	}
	inline bool chk(int t){return push(u[t],v[t],0)&&push(u[t],v[t],1)&&push(v[t],u[t],0)&&push(v[t],u[t],1);}
	inline void ins(int t){push(u[t],v[t],0);pebble[frmx[t]=u[t]][frmt[t]=0]=t;}
	inline void clear(){pebble.assign(n,{-1,-1});}
};
template<class M1,class M2>struct MatroidIntersection{
	int n;M1 m1;M2 m2;vector<int> inI,lst;queue<int> q;
	MatroidIntersection(int n_,M1 m1_,M2 m2_):n(n_),m1(m1_),m2(m2_),inI(n_){}
	inline vector<int> RtoL(int t){
		vector<int> res;
		m1.clear();
		for(int i=0;i<n;++i) if(inI[i]&&i-t) m1.ins(i);
		for(int i=0;i<n;++i) if(!inI[i]&&lst[i]<0&&m1.chk(i)) res.push_back(i),lst[i]=t;
		return res;
	}
	inline int LtoR(int t){
		m2.clear();
		for(int i=0;i<2;++i) for(int j=0;j<n;++j) if((j==t||inI[j])&&(lst[j]<0)==i){
			if(!m2.chk(j))
				if(i){q.push(j);lst[j]=t;return j;}
				else return -1;
			m2.ins(j);
		}
		return n;
	}
	inline bool augment(){
		lst.assign(n,-1);
		for(q.push(n);!q.empty();q.pop()) for(auto i:RtoL(q.front())) for(int j;(j=LtoR(i))>=0;) if(j==n){
			for(;i^n;i=lst[i]) inI[i]^=1;
			return true;
		}
		return false;
	}
	inline vector<int> slv(){
		for(int i=0;i<n;++i) if(m1.chk(i)&&m2.chk(i)) inI[i]=1,m1.ins(i),m2.ins(i);
		for(;augment(););
		vector<int> res;
		for(int i=0;i<n;++i) if(inI[i]) res.push_back(i);
		return res;
	}
};
int main(){
	scanf("%d%d",&n,&m);
	u.resize(m);v.resize(m);c.resize(m);
	for(int i=0;i<m;++i) scanf("%d%d%d",&u[i],&v[i],&c[i]);
	printf("%llu",n*2-MatroidIntersection(m,color(m,c),rigidity(n,m,u,v)).slv().size());
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 2948kb

input:

3 3
0 1 0
0 2 0
1 2 0

output:

5

result:

ok 1 number(s): "5"

Test #2:

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

input:

3 3
0 1 0
0 2 1
1 2 2

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

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

output:

4

result:

ok 1 number(s): "4"

Test #4:

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

input:

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

output:

6

result:

ok 1 number(s): "6"

Test #5:

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

input:

2 0

output:

4

result:

ok 1 number(s): "4"

Test #6:

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

input:

2 1
0 1 0

output:

3

result:

ok 1 number(s): "3"

Test #7:

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

input:

2 2
0 1 0
0 1 1

output:

3

result:

ok 1 number(s): "3"

Test #8:

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

input:

2 3
0 1 0
0 1 2
0 1 0

output:

3

result:

ok 1 number(s): "3"

Test #9:

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

input:

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

output:

3

result:

ok 1 number(s): "3"

Test #10:

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

input:

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

output:

3

result:

ok 1 number(s): "3"

Test #11:

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

input:

2 6
0 1 3
0 1 3
0 1 1
0 1 0
0 1 3
0 1 4

output:

3

result:

ok 1 number(s): "3"

Test #12:

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

input:

2 7
0 1 1
0 1 5
0 1 6
0 1 4
0 1 1
0 1 2
0 1 3

output:

3

result:

ok 1 number(s): "3"

Test #13:

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

input:

2 8
0 1 2
0 1 5
0 1 1
0 1 4
0 1 2
0 1 1
0 1 1
0 1 1

output:

3

result:

ok 1 number(s): "3"

Test #14:

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

input:

2 9
0 1 8
0 1 7
0 1 0
0 1 7
0 1 4
0 1 1
0 1 2
0 1 8
0 1 5

output:

3

result:

ok 1 number(s): "3"

Test #15:

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

input:

2 10
0 1 0
0 1 7
0 1 8
0 1 5
0 1 8
0 1 7
0 1 8
0 1 3
0 1 4
0 1 3

output:

3

result:

ok 1 number(s): "3"

Test #16:

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

input:

3 0

output:

6

result:

ok 1 number(s): "6"

Test #17:

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

input:

3 1
1 2 0

output:

5

result:

ok 1 number(s): "5"

Test #18:

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

input:

3 2
1 2 1
1 2 1

output:

5

result:

ok 1 number(s): "5"

Test #19:

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

input:

3 3
1 2 2
1 2 1
0 1 1

output:

4

result:

ok 1 number(s): "4"

Test #20:

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

input:

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

output:

4

result:

ok 1 number(s): "4"

Test #21:

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

input:

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

output:

3

result:

ok 1 number(s): "3"

Test #22:

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

input:

3 6
1 2 4
0 1 1
0 2 5
1 2 1
0 2 3
0 1 4

output:

3

result:

ok 1 number(s): "3"

Test #23:

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

input:

3 7
1 2 6
1 2 2
1 2 4
1 2 6
1 2 1
0 2 2
0 1 6

output:

3

result:

ok 1 number(s): "3"

Test #24:

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

input:

3 8
1 2 6
0 1 2
0 1 4
0 2 3
1 2 1
1 2 0
0 2 4
1 2 4

output:

3

result:

ok 1 number(s): "3"

Test #25:

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

input:

3 9
1 2 8
1 2 4
1 2 4
1 2 8
1 2 8
1 2 4
1 2 7
0 1 3
0 2 2

output:

3

result:

ok 1 number(s): "3"

Test #26:

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

input:

3 10
0 1 9
0 2 4
0 1 0
0 1 9
1 2 4
0 1 9
1 2 9
1 2 5
1 2 5
0 1 0

output:

3

result:

ok 1 number(s): "3"

Test #27:

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

input:

4 0

output:

8

result:

ok 1 number(s): "8"

Test #28:

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

input:

4 1
1 3 0

output:

7

result:

ok 1 number(s): "7"

Test #29:

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

input:

4 2
0 1 0
1 2 0

output:

7

result:

ok 1 number(s): "7"

Test #30:

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

input:

4 3
0 3 0
2 3 1
0 3 1

output:

6

result:

ok 1 number(s): "6"

Test #31:

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

input:

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

output:

6

result:

ok 1 number(s): "6"

Test #32:

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

input:

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

output:

5

result:

ok 1 number(s): "5"

Test #33:

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

input:

4 6
1 3 1
0 2 5
0 3 0
0 2 3
1 3 2
0 3 4

output:

5

result:

ok 1 number(s): "5"

Test #34:

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

input:

4 7
1 2 4
0 3 4
0 2 1
2 3 4
0 2 0
0 1 1
1 3 3

output:

4

result:

ok 1 number(s): "4"

Test #35:

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

input:

4 8
0 2 1
0 3 7
1 3 7
2 3 3
1 2 0
2 3 7
1 2 0
2 3 0

output:

4

result:

ok 1 number(s): "4"

Test #36:

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

input:

4 9
0 2 5
0 3 0
1 2 5
0 2 1
2 3 1
1 3 7
1 3 2
2 3 5
0 2 8

output:

3

result:

ok 1 number(s): "3"

Test #37:

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

input:

4 10
1 2 0
0 2 0
2 3 0
0 1 1
2 3 8
1 2 2
0 3 9
1 3 6
1 2 6
1 2 4

output:

3

result:

ok 1 number(s): "3"

Test #38:

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

input:

5 0

output:

10

result:

ok 1 number(s): "10"

Test #39:

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

input:

5 1
0 4 0

output:

9

result:

ok 1 number(s): "9"

Test #40:

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

input:

5 2
0 3 0
0 3 1

output:

9

result:

ok 1 number(s): "9"

Test #41:

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

input:

5 3
0 2 0
1 4 2
1 2 2

output:

8

result:

ok 1 number(s): "8"

Test #42:

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

input:

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

output:

8

result:

ok 1 number(s): "8"

Test #43:

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

input:

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

output:

7

result:

ok 1 number(s): "7"

Test #44:

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

input:

5 6
0 2 2
3 4 5
0 3 4
1 2 5
1 2 1
3 4 4

output:

6

result:

ok 1 number(s): "6"

Test #45:

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

input:

5 7
0 1 0
0 2 6
3 4 3
3 4 0
0 2 6
3 4 6
3 4 4

output:

7

result:

ok 1 number(s): "7"

Test #46:

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

input:

5 8
0 4 5
2 4 4
1 2 3
1 4 2
0 3 7
2 3 6
3 4 3
3 4 4

output:

4

result:

ok 1 number(s): "4"

Test #47:

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

input:

5 9
0 2 5
0 2 4
0 2 8
2 4 3
0 1 3
2 4 3
2 3 8
0 3 8
3 4 4

output:

6

result:

ok 1 number(s): "6"

Test #48:

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

input:

5 10
0 2 9
3 4 7
0 3 9
0 2 3
2 4 4
3 4 3
2 3 1
0 1 9
3 4 9
2 3 8

output:

5

result:

ok 1 number(s): "5"

Test #49:

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

input:

6 0

output:

12

result:

ok 1 number(s): "12"

Test #50:

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

input:

6 1
2 4 0

output:

11

result:

ok 1 number(s): "11"

Test #51:

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

input:

6 2
1 4 1
0 4 0

output:

10

result:

ok 1 number(s): "10"

Test #52:

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

input:

6 3
1 3 1
1 4 2
0 2 0

output:

9

result:

ok 1 number(s): "9"

Test #53:

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

input:

6 4
0 3 1
4 5 1
3 5 1
2 5 2

output:

10

result:

ok 1 number(s): "10"

Test #54:

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

input:

6 5
0 1 4
0 4 1
3 4 4
1 5 0
3 5 0

output:

9

result:

ok 1 number(s): "9"

Test #55:

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

input:

6 6
4 5 5
2 3 4
3 5 4
1 3 0
4 5 0
1 3 4

output:

9

result:

ok 1 number(s): "9"

Test #56:

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

input:

6 7
4 5 5
3 5 3
1 2 1
2 5 2
1 5 5
3 4 4
1 3 1

output:

7

result:

ok 1 number(s): "7"

Test #57:

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

input:

6 8
3 5 0
4 5 1
2 5 6
1 5 2
3 5 6
0 3 4
4 5 7
0 3 7

output:

7

result:

ok 1 number(s): "7"

Test #58:

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

input:

6 9
3 4 3
2 5 1
2 3 3
3 4 4
0 3 5
2 3 7
0 5 2
0 5 3
1 3 1

output:

7

result:

ok 1 number(s): "7"

Test #59:

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

input:

6 10
0 3 8
3 4 4
2 5 1
4 5 4
3 5 8
0 5 4
2 3 0
0 1 0
3 4 0
0 2 2

output:

7

result:

ok 1 number(s): "7"

Test #60:

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

input:

7 0

output:

14

result:

ok 1 number(s): "14"

Test #61:

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

input:

7 1
0 5 0

output:

13

result:

ok 1 number(s): "13"

Test #62:

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

input:

7 2
2 6 0
5 6 0

output:

13

result:

ok 1 number(s): "13"

Test #63:

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

input:

7 3
5 6 1
0 6 0
2 4 0

output:

12

result:

ok 1 number(s): "12"

Test #64:

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

input:

7 4
1 6 2
2 5 3
0 3 3
3 4 2

output:

12

result:

ok 1 number(s): "12"

Test #65:

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

input:

7 5
4 6 0
5 6 1
1 3 3
3 6 0
2 6 2

output:

10

result:

ok 1 number(s): "10"

Test #66:

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

input:

7 6
0 1 5
0 5 4
5 6 3
1 3 2
3 6 5
1 4 4

output:

10

result:

ok 1 number(s): "10"

Test #67:

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

input:

7 7
3 4 1
3 5 6
5 6 3
2 3 5
5 6 4
0 1 2
5 6 2

output:

9

result:

ok 1 number(s): "9"

Test #68:

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

input:

7 8
5 6 3
4 6 6
3 4 1
0 2 1
1 6 5
5 6 3
5 6 2
5 6 3

output:

10

result:

ok 1 number(s): "10"

Test #69:

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

input:

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

output:

8

result:

ok 1 number(s): "8"

Test #70:

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

input:

7 10
4 6 6
4 5 1
1 4 0
4 6 6
4 5 1
4 6 7
3 5 2
5 6 1
0 4 4
2 3 9

output:

8

result:

ok 1 number(s): "8"

Test #71:

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

input:

8 0

output:

16

result:

ok 1 number(s): "16"

Test #72:

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

input:

8 1
0 3 0

output:

15

result:

ok 1 number(s): "15"

Test #73:

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

input:

8 2
0 6 1
5 7 1

output:

15

result:

ok 1 number(s): "15"

Test #74:

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

input:

8 3
1 6 1
0 3 2
0 2 2

output:

14

result:

ok 1 number(s): "14"

Test #75:

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

input:

8 4
1 5 0
5 7 2
2 7 1
3 4 1

output:

13

result:

ok 1 number(s): "13"

Test #76:

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

input:

8 5
2 6 3
1 5 1
6 7 0
6 7 2
4 5 4

output:

12

result:

ok 1 number(s): "12"

Test #77:

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

input:

8 6
2 6 2
6 7 2
2 5 3
3 5 4
0 3 4
0 1 0

output:

12

result:

ok 1 number(s): "12"

Test #78:

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

input:

8 7
3 5 6
2 4 3
4 7 0
5 6 1
3 4 5
6 7 0
5 6 6

output:

11

result:

ok 1 number(s): "11"

Test #79:

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

input:

8 8
3 4 7
0 7 3
1 6 5
3 7 1
5 7 4
0 7 2
3 7 6
0 4 6

output:

10

result:

ok 1 number(s): "10"

Test #80:

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

input:

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

output:

11

result:

ok 1 number(s): "11"

Test #81:

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

input:

8 10
4 6 7
4 5 7
2 3 2
0 6 8
3 4 7
4 5 8
5 6 1
0 2 3
1 7 5
4 7 3

output:

10

result:

ok 1 number(s): "10"

Test #82:

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

input:

9 0

output:

18

result:

ok 1 number(s): "18"

Test #83:

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

input:

9 1
0 6 0

output:

17

result:

ok 1 number(s): "17"

Test #84:

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

input:

9 2
0 1 0
1 4 0

output:

17

result:

ok 1 number(s): "17"

Test #85:

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

input:

9 3
0 3 2
4 8 2
4 8 2

output:

17

result:

ok 1 number(s): "17"

Test #86:

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

input:

9 4
0 6 2
0 2 0
1 5 2
3 7 1

output:

15

result:

ok 1 number(s): "15"

Test #87:

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

input:

9 5
0 1 4
3 6 4
6 8 4
6 8 3
6 8 1

output:

16

result:

ok 1 number(s): "16"

Test #88:

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

input:

9 6
0 4 5
6 8 0
3 4 3
2 6 5
5 6 3
4 5 0

output:

15

result:

ok 1 number(s): "15"

Test #89:

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

input:

9 7
0 6 1
2 5 5
0 7 5
5 8 3
5 6 5
3 5 0
2 6 0

output:

14

result:

ok 1 number(s): "14"

Test #90:

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

input:

9 8
0 1 2
5 8 0
5 7 0
0 8 0
4 8 3
2 7 1
1 5 1
5 8 2

output:

14

result:

ok 1 number(s): "14"

Test #91:

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

input:

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

output:

13

result:

ok 1 number(s): "13"

Test #92:

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

input:

9 10
3 8 6
5 8 4
3 6 2
2 7 9
4 7 1
0 5 9
5 6 3
7 8 4
5 6 6
0 1 7

output:

11

result:

ok 1 number(s): "11"

Test #93:

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

input:

10 0

output:

20

result:

ok 1 number(s): "20"

Test #94:

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

input:

10 1
3 4 0

output:

19

result:

ok 1 number(s): "19"

Test #95:

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

input:

10 2
3 9 0
3 9 1

output:

19

result:

ok 1 number(s): "19"

Test #96:

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

input:

10 3
2 5 1
1 5 0
8 9 0

output:

18

result:

ok 1 number(s): "18"

Test #97:

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

input:

10 4
2 5 1
1 7 3
5 6 2
3 6 2

output:

17

result:

ok 1 number(s): "17"

Test #98:

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

input:

10 5
1 9 0
1 9 0
0 8 4
5 9 3
5 6 4

output:

17

result:

ok 1 number(s): "17"

Test #99:

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

input:

10 6
0 2 4
8 9 4
5 7 2
8 9 1
7 9 3
4 8 1

output:

16

result:

ok 1 number(s): "16"

Test #100:

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

input:

10 7
0 5 0
7 8 3
2 6 2
0 1 2
8 9 3
6 7 6
0 1 5

output:

15

result:

ok 1 number(s): "15"

Test #101:

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

input:

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

output:

14

result:

ok 1 number(s): "14"

Test #102:

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

input:

10 9
8 9 0
5 6 5
1 2 1
5 8 2
3 9 0
1 9 6
0 2 0
8 9 0
6 7 8

output:

14

result:

ok 1 number(s): "14"

Test #103:

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

input:

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

output:

14

result:

ok 1 number(s): "14"

Test #104:

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

input:

200 200
20 56 24
7 129 170
89 143 66
182 187 59
1 192 60
9 181 125
164 165 175
131 195 90
118 159 152
31 46 182
74 85 3
79 97 145
66 186 161
69 93 67
102 153 82
108 194 174
67 123 59
130 171 127
159 187 65
17 54 125
138 153 92
188 199 168
30 175 165
39 96 18
58 61 191
109 156 65
181 195 1
173 183 58...

output:

264

result:

ok 1 number(s): "264"

Test #105:

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

input:

200 400
6 148 31
37 91 362
22 116 182
168 173 279
140 149 370
55 176 208
96 115 21
65 109 58
52 180 342
46 112 203
97 116 237
151 187 77
63 151 132
35 49 75
115 120 151
188 197 194
13 138 68
32 40 113
60 69 284
127 151 73
189 194 351
125 191 188
103 166 355
79 174 161
57 149 158
15 185 238
39 52 343...

output:

131

result:

ok 1 number(s): "131"

Test #106:

score: -100
Time Limit Exceeded

input:

200 600
175 194 1
153 196 511
82 94 559
89 133 81
136 182 584
190 194 340
102 116 208
176 196 205
76 153 578
164 176 238
35 187 356
97 151 178
47 64 166
100 162 300
67 157 441
179 192 413
118 186 25
11 26 93
42 163 388
82 107 327
30 117 266
156 170 87
160 195 445
195 196 460
97 169 224
95 111 424
19...

output:


result: