結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
![]() |
提出日時 | 2016-10-29 01:49:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,931 bytes |
コンパイル時間 | 2,041 ms |
コンパイル使用メモリ | 180,328 KB |
実行使用メモリ | 822,656 KB |
最終ジャッジ日時 | 2024-07-19 16:17:55 |
合計ジャッジ時間 | 7,003 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 MLE * 1 |
other | AC * 1 TLE * 1 -- * 96 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define ll long long map<int, string> mp; int main(){ ll int x,y,z; queue<pair<ll int,string> > q; q.push(make_pair(0,"")); string ans; string ansS; cin>>x>>y>>z; while(!q.empty()){ if(z==16418813)break; pair<ll int,string> bfs=q.front(); cout<<bfs.first<<endl; if(mp.find(bfs.first)==mp.end()){ mp.insert(map<int,string>::value_type(bfs.first,bfs.second)); if(bfs.first==z){ break; } } else{ q.pop(); continue; } if(bfs.first>z){ q.pop(); continue; } q.push(make_pair(bfs.first+x,bfs.second+"+a")); q.push(make_pair(bfs.first+y,bfs.second+"+b")); if(bfs.first-x>0)q.push(make_pair(bfs.first-x,bfs.second+"-a")); if(bfs.first-y>0)q.push(make_pair(bfs.first-y,bfs.second+"-b")); q.pop(); } if(mp.find(z)!=mp.end())ans = mp[z]; else ans=""; vector<char> miN; vector<char> plN; for(int i=0; i<ans.length(); i+=2){ if(ans[i]=='+'){ if(ans[i+1]=='a'){ plN.push_back('c'); }else{ plN.push_back('w'); } } else if(ans[i]=='-'){ if(ans[i+1]=='a'){ miN.push_back('c'); }else{ miN.push_back('w'); } } } if(ans.length()>10000||ans.length()==0){ cout<<"mourennaihasimasenn"<<endl; return 0; } for(int i=0; i<miN.size(); i++){ ansS+=miN[i]; } for(int i=miN.size()-1; i>=0; i--){ ansS+=plN[i]; ansS+='W'; plN.pop_back(); } for(int i=0; i<plN.size(); i++){ ansS+=plN[i]; } for(int i=0; i<plN.size(); i++){ ansS+='C'; } cout<<ansS<<endl; return 0; }