結果

問題 No.917 Make One With GCD
ユーザー asdf1asdf1
提出日時 2019-10-25 22:31:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,152 bytes
コンパイル時間 3,285 ms
コンパイル使用メモリ 211,996 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 05:28:07
合計ジャッジ時間 7,398 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/ios:40,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/istream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/sstream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/complex:45,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ccomplex:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:54,
         次から読み込み:  main.cpp:1:
静的メンバ関数 ‘static constexpr void std::char_traits<char>::assign(char_type&, const char_type&)’ 内,
    inlined from ‘void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/local/gcc7/include/c++/12.2.0/bits/basic_string.h:1529:21,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/local/gcc7/include/c++/12.2.0/bits/basic_string.h:1351:17,
    inlined from ‘int main()’ at main.cpp:54:12:
/usr/local/gcc7/include/c++/12.2.0/bits/char_traits.h:354:14: 警告: ‘aga’ may be used uninitialized [-Wmaybe-uninitialized]
  354 |         __c1 = __c2;
      |         ~~~~~^~~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:47:14: 備考: ‘aga’ はここで定義されています
   47 |         char aga;
      |              ^~~

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
unordered_map<string,ll> mp;
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n){
        char aga;
        for(char c='1';c<='9';c++){
            if((c-'0')==a[i]){
                aga=c;
                break;
            }
        }
        s+=aga;
    }
    queue<string> que;
    que.push(s);
    mp[s]=1;
        while(1){
            if(que.empty())break;
            string co=que.front();
            que.pop();
            cnt=0;
            rep(j,Size(co)){
                if(co[j]=='a')continue;
                tmp=co[j]-'0';
                cnt=__gcd(cnt,tmp);
            }
            if(cnt!=1)continue;
            ans++;
            rep(i,Size(co)){
                string koutiku="";
                rep(j,Size(co)){
                    if(i==j)koutiku+="a";
                    else koutiku+=co[j];
                }
                if(mp[koutiku]==1)continue;
                mp[koutiku]=1;
                que.push(koutiku);
            } 
        }
        Cout(ans);
    return 0;
}
0