結果
| 問題 |
No.232 めぐるはめぐる (2)
|
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2015-06-26 23:00:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,298 bytes |
| コンパイル時間 | 809 ms |
| コンパイル使用メモリ | 90,800 KB |
| 実行使用メモリ | 7,168 KB |
| 最終ジャッジ日時 | 2024-07-07 18:19:23 |
| 合計ジャッジ時間 | 2,547 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 4 |
ソースコード
#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
#define input_init stringstream ss; string strtoken, token; istringstream is
#define input_line getline(cin, strtoken);is.str(strtoken);is.clear(istringstream::goodbit)
#define input_token(num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num
int main(void){
int T,A,B;
cin >> T >> A >> B;
vector<string> res(T);
vector<pair<int, int>> xy(T+1);
xy[T].first = A;
xy[T].second = B;
for (int i = T-1; i >= 0; i--){
if (abs(xy[i + 1].first) > abs(xy[i + 1].second)){
if (abs(i+1 - xy[i + 1].first) & 1){
if (xy[i + 1].second >= 0){
res[i] += ">";
xy[i].second = xy[i + 1].second - 1;
}
else {
res[i] += "<";
xy[i].second = xy[i + 1].second + 1;
}
xy[i].first = xy[i + 1].first;
}
else{
if (xy[i + 1].first >= 0){
res[i] += "^";
xy[i].first = xy[i + 1].first -1;
}
else {
res[i] += "v";
xy[i].first = xy[i + 1].first + 1;
}
if (xy[i + 1].second >= 0){
res[i] += ">";
xy[i].second = xy[i + 1].second - 1;
}
else {
res[i] += "<";
xy[i].second = xy[i + 1].second + 1;
}
}
}
else{
if (abs(i + 1 - xy[i + 1].second) & 1){
if (xy[i + 1].first >= 0){
res[i] += "^";
xy[i].first = xy[i + 1].first - 1;
}
else {
res[i] += "v";
xy[i].first = xy[i + 1].first + 1;
}
xy[i].second = xy[i + 1].second;
}
else{
if (xy[i + 1].second >= 0){
res[i] += ">";
xy[i].second = xy[i + 1].second - 1;
}
else {
res[i] += "<";
xy[i].second = xy[i + 1].second + 1;
}
if (xy[i + 1].first >= 0){
res[i] += "^";
xy[i].first = xy[i + 1].first - 1;
}
else {
res[i] += "v";
xy[i].first = xy[i + 1].first + 1;
}
}
}
}
if (xy[0].first == 0 && xy[0].second == 0){
cout << "YES" << endl;
for (int i = T - 1; i >= 0; i--)cout << res[i] << endl;
}
else cout << "NO" << endl;
return(0);
}
btk