結果

問題 No.774 tatyamと素数大富豪
ユーザー chocopuuchocopuu
提出日時 2018-12-22 04:03:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,645 bytes
コンパイル時間 3,382 ms
コンパイル使用メモリ 185,940 KB
実行使用メモリ 90,684 KB
最終ジャッジ日時 2023-10-26 01:57:42
合計ジャッジ時間 26,249 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,212 ms
90,684 KB
testcase_01 AC 845 ms
85,300 KB
testcase_02 AC 954 ms
85,300 KB
testcase_03 AC 919 ms
85,300 KB
testcase_04 AC 859 ms
85,300 KB
testcase_05 AC 923 ms
85,300 KB
testcase_06 AC 914 ms
85,300 KB
testcase_07 WA -
testcase_08 AC 867 ms
85,300 KB
testcase_09 AC 960 ms
85,300 KB
testcase_10 AC 1,079 ms
85,300 KB
testcase_11 AC 1,017 ms
85,300 KB
testcase_12 AC 1,073 ms
85,300 KB
testcase_13 AC 1,072 ms
85,300 KB
testcase_14 AC 853 ms
85,300 KB
testcase_15 AC 1,041 ms
85,300 KB
testcase_16 AC 999 ms
85,300 KB
testcase_17 AC 1,063 ms
85,300 KB
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:87:9: warning: 'ok' may be used uninitialized [-Wmaybe-uninitialized]
   87 |         if(ok){
      |         ^~
main.cpp:74:10: note: 'ok' was declared here
   74 |     bool ok;
      |          ^~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
string s[13];
unordered_map<string,int>mp;

vector<int> P;
void make_primes(int n)
{
	vector<bool> primes;

	primes.resize(n + 1, true);
	primes[0] = primes[1] = false;
	rep(i, 2, sqrt(n)) if (primes[i]) for (int j = 0; i * (j + 2) < n; j++)
		primes[i * (j + 2)] = false;

	rep(i, 2, n + 1) if (primes[i]) P.push_back(i);
}

int perm2[13];
void permtation2(int n){
  for(int i=0;i<n;i++){
    perm2[i]=i;
  }
  do{
      string tmp="";
    rep(i,0,n)tmp=tmp+s[perm2[i]];
    mp[tmp]++;
  }while(next_permutation(perm2,perm2+n));
  return ;
}

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
   cin>>N;
   rep(i,0,N){
       cin>>s[i];
   }
   
    make_primes(131313131);  
    permtation2(N);
    std::priority_queue<int>pq;
    bool ok;
    for(auto e:mp)pq.push(stol(e.fi));
    while(!pq.empty()){
        int q=pq.top();
        pq.pop();
        //cout<<q<<endl;
        for(auto e:P){
            ok=true;
            if(q%e==0){
                if(q!=e)ok=false;
                break;
            }
        }
        if(ok){
            if(q%(int)sqrt(q)!=0){
        cout<<q<<endl;
        return 0;
            }
    }
    }
    
    cout<<-1<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}
0