結果

問題 No.1773 Love Triangle
ユーザー BloodWuRenBloodWuRen
提出日時 2023-05-04 22:13:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 1,136 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 167,580 KB
実行使用メモリ 4,736 KB
最終ジャッジ日時 2023-08-14 14:17:19
合計ジャッジ時間 17,161 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 119 ms
4,512 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 6 ms
4,384 KB
testcase_24 AC 6 ms
4,380 KB
testcase_25 AC 19 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 88 ms
4,380 KB
testcase_31 AC 7 ms
4,380 KB
testcase_32 AC 3 ms
4,428 KB
testcase_33 AC 2 ms
4,452 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 29 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 223 ms
4,488 KB
testcase_39 AC 222 ms
4,544 KB
testcase_40 AC 229 ms
4,488 KB
testcase_41 AC 251 ms
4,508 KB
testcase_42 AC 256 ms
4,528 KB
testcase_43 AC 252 ms
4,652 KB
testcase_44 AC 241 ms
4,492 KB
testcase_45 AC 222 ms
4,584 KB
testcase_46 AC 245 ms
4,536 KB
testcase_47 AC 243 ms
4,720 KB
testcase_48 AC 235 ms
4,440 KB
testcase_49 AC 233 ms
4,444 KB
testcase_50 AC 229 ms
4,652 KB
testcase_51 AC 255 ms
4,424 KB
testcase_52 AC 241 ms
4,724 KB
testcase_53 AC 230 ms
4,516 KB
testcase_54 AC 223 ms
4,504 KB
testcase_55 AC 244 ms
4,620 KB
testcase_56 AC 226 ms
4,484 KB
testcase_57 AC 234 ms
4,504 KB
testcase_58 AC 226 ms
4,504 KB
testcase_59 AC 237 ms
4,532 KB
testcase_60 AC 232 ms
4,604 KB
testcase_61 AC 224 ms
4,472 KB
testcase_62 AC 231 ms
4,504 KB
testcase_63 AC 222 ms
4,736 KB
testcase_64 AC 239 ms
4,532 KB
testcase_65 AC 232 ms
4,540 KB
testcase_66 AC 252 ms
4,524 KB
testcase_67 AC 232 ms
4,464 KB
testcase_68 AC 243 ms
4,736 KB
testcase_69 AC 237 ms
4,736 KB
testcase_70 AC 224 ms
4,532 KB
testcase_71 AC 237 ms
4,468 KB
testcase_72 AC 227 ms
4,536 KB
testcase_73 AC 234 ms
4,604 KB
testcase_74 AC 238 ms
4,504 KB
testcase_75 AC 241 ms
4,620 KB
testcase_76 AC 216 ms
4,460 KB
testcase_77 AC 223 ms
4,444 KB
testcase_78 AC 1 ms
4,376 KB
testcase_79 AC 3 ms
4,564 KB
testcase_80 AC 5 ms
4,532 KB
testcase_81 AC 124 ms
4,536 KB
testcase_82 AC 89 ms
4,568 KB
testcase_83 AC 34 ms
4,380 KB
testcase_84 AC 36 ms
4,380 KB
testcase_85 AC 36 ms
4,564 KB
testcase_86 AC 7 ms
4,376 KB
testcase_87 AC 17 ms
4,376 KB
testcase_88 AC 4 ms
4,404 KB
testcase_89 AC 11 ms
4,376 KB
testcase_90 AC 82 ms
4,528 KB
testcase_91 AC 62 ms
4,388 KB
testcase_92 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
const int mod=1e9+7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,m,u[1010][3],a[510][510];
void qmo(int &x){
	x+=(x>>31)&mod;
}
int ksm(int a,int k){
	int res=1;
	for(;k;k>>=1,a=1ll*a*a%mod) if(k&1) res=1ll*res*a%mod;
	return res;
}
int qry_rank(){
	int k=0;
	for(int j=1;j<=n;j++){
		int p=0;
		for(int i=k+1;i<=n;i++) if(a[i][j]){
			p=i;
			break;
		}
		if(!p) continue;
		k++;
		for(int i=1;i<=n;i++) swap(a[p][i],a[k][i]);
		int inv=ksm(a[k][j],mod-2);
		for(int i=1;i<=n;i++) a[k][i]=1ll*a[k][i]*inv%mod;
		for(int i=k+1;i<=n;i++) if(a[i][j]){
			int mul=a[i][j];
			for(int l=1;l<=n;l++) a[i][l]=(a[i][l]-1ll*mul*a[k][l]%mod+mod)%mod;
		}
	}
	return k;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++) for(int j=0;j<3;j++) scanf("%d",&u[i][j]);
	int k=0;
	for(int _=0;_<2;_++){
		for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) a[i][j]=0;
		for(int i=0;i<m;i++){
			int x=rng()%mod;
			for(int j=0;j<3;j++){
				qmo(a[u[i][j]][u[i][(j+1)%3]]+=x-mod);
				qmo(a[u[i][(j+1)%3]][u[i][j]]-=x);
			}
		}
		k=max(k,qry_rank());
	}
	printf("%d\n",k/2);
}
0