結果
| 問題 |
No.400 鏡
|
| コンテスト | |
| ユーザー |
hamray
|
| 提出日時 | 2017-11-14 21:09:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,613 bytes |
| コンパイル時間 | 676 ms |
| コンパイル使用メモリ | 77,188 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-25 02:14:19 |
| 合計ジャッジ時間 | 1,151 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 8 |
ソースコード
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<stack>
using namespace std;
int main(){
string S; cin >> S;
cout << S.size();
string head, cent, tail;
if(S.size() % 2 == 0){
head = S.substr(0, S.size() / 2 );
tail = S.substr(S.size() / 2, S.size() - 1);
reverse(tail.begin(), tail.end());
for(int i = 0; i < S.size() / 2; i++){
char key;
if(head[i] == tail[i]){
if(tail[i] =='>'){
tail[i] = '<';
head[i] = tail[i];
}else{
tail[i] = '>';
head[i] = tail[i];
}
}
}
reverse(tail.begin(), tail.end());
cout << head + tail << endl;
}else{
head = S.substr(0, (S.size()-1) / 2);
cent = S[(S.size() - 1) / 2];
tail = S.substr((S.size() - 1)/ 2+1 , S.size() - 1);
if(cent == "<") {
cent = ">";
}else{
cent = "<";
}
reverse(tail.begin(), tail.end());
for(int i = 0; i < (S.size() - 1) / 2; i++){
if(head[i] == tail[i]){
if(tail[i] =='>'){
tail[i] = '<';
head[i] = tail[i];
}else{
tail[i] = '>';
head[i] = tail[i];
}
}
}
reverse(tail.begin(), tail.end());
cout << head + cent + tail << endl;
}
return 0;
}
hamray