結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
ouoz1V
|
| 提出日時 | 2016-10-29 01:40:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,808 bytes |
| コンパイル時間 | 1,423 ms |
| コンパイル使用メモリ | 171,628 KB |
| 実行使用メモリ | 1,529,212 KB |
| 最終ジャッジ日時 | 2024-11-24 22:56:13 |
| 合計ジャッジ時間 | 130,803 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 MLE * 1 |
| other | AC * 17 WA * 24 RE * 2 TLE * 32 MLE * 23 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string method[10000000];
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(method[bfs.first].length()==0){
method[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=method[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