結果

問題 No.1955 Not Prime
ユーザー 沙耶花沙耶花
提出日時 2022-05-20 23:16:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 4,999 ms
コンパイル使用メモリ 268,184 KB
実行使用メモリ 27,056 KB
最終ジャッジ日時 2023-10-20 14:09:24
合計ジャッジ時間 6,399 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,348 KB
testcase_01 AC 8 ms
4,348 KB
testcase_02 AC 8 ms
4,348 KB
testcase_03 AC 8 ms
4,348 KB
testcase_04 AC 8 ms
4,348 KB
testcase_05 AC 8 ms
4,348 KB
testcase_06 AC 10 ms
4,348 KB
testcase_07 AC 50 ms
4,848 KB
testcase_08 AC 44 ms
4,592 KB
testcase_09 AC 75 ms
4,592 KB
testcase_10 AC 73 ms
4,348 KB
testcase_11 AC 84 ms
27,056 KB
testcase_12 AC 26 ms
4,348 KB
testcase_13 AC 75 ms
4,848 KB
testcase_14 AC 19 ms
4,348 KB
testcase_15 AC 19 ms
4,348 KB
testcase_16 AC 35 ms
4,592 KB
testcase_17 AC 65 ms
6,152 KB
testcase_18 AC 75 ms
4,848 KB
testcase_19 AC 76 ms
5,640 KB
testcase_20 AC 8 ms
4,348 KB
testcase_21 AC 28 ms
4,348 KB
testcase_22 AC 8 ms
4,348 KB
testcase_23 AC 8 ms
4,348 KB
testcase_24 AC 8 ms
4,348 KB
testcase_25 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
vector<bool> f(1000000,true);

bool check(int a,int b){
	string s = to_string(a);
	s += to_string(b);
	return f[stoi(s)];
}

int main() {
    
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	
	
	f[1] = false;
	for(int i=2;i<f.size();i++){
		if(!f[i])continue;
		for(int j=i*2;j<f.size();j+=i)f[j] = false;
	}
	two_sat S(n);
	
	rep(i,n){
		rep(j,n){
			
			if(check(a[i],b[j])){
				S.add_clause(i,1,j,1);
			}
			if(check(b[i],a[j])){
				S.add_clause(i,0,j,0);
			}
			if(check(a[i],a[j])){
				S.add_clause(i,1,j,0);
			}
			if(check(b[i],b[j])){
				S.add_clause(i,0,j,1);
			}		
			
		}
	}
	if(S.satisfiable())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
    return 0;
}
0