結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
ouoz1V
|
| 提出日時 | 2016-10-29 01:40:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,833 bytes |
| コンパイル時間 | 1,787 ms |
| コンパイル使用メモリ | 180,980 KB |
| 実行使用メモリ | 1,219,396 KB |
| 最終ジャッジ日時 | 2024-11-24 22:57:27 |
| 合計ジャッジ時間 | 66,541 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 24 WA * 43 RE * 9 TLE * 5 MLE * 17 |
ソースコード
#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()){
pair<ll int,string> bfs=q.front();
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+x+y){
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();
}
ans = mp[z];
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;
}
ouoz1V