結果
問題 |
No.917 Make One With GCD
|
ユーザー |
![]() |
提出日時 | 2019-10-25 22:31:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,152 bytes |
コンパイル時間 | 2,765 ms |
コンパイル使用メモリ | 206,844 KB |
最終ジャッジ日時 | 2025-01-08 01:30:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 7 WA * 16 TLE * 9 |
コンパイルメッセージ
In file included from /usr/include/c++/13/string:42, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from main.cpp:1: In static member function ‘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/include/c++/13/bits/basic_string.h:1566: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/include/c++/13/bits/basic_string.h:1388:17, inlined from ‘int main()’ at main.cpp:54:12: /usr/include/c++/13/bits/char_traits.h:358:14: warning: ‘aga’ may be used uninitialized [-Wmaybe-uninitialized] 358 | __c1 = __c2; | ~~~~~^~~~~~ main.cpp: In function ‘int main()’: main.cpp:47:14: note: ‘aga’ was declared here 47 | char aga; | ^~~
ソースコード
#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; }