結果
| 問題 |
No.232 めぐるはめぐる (2)
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-06 00:11:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,445 bytes |
| コンパイル時間 | 2,313 ms |
| コンパイル使用メモリ | 204,368 KB |
| 最終ジャッジ日時 | 2025-01-09 14:27:51 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 11 |
ソースコード
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
lint cabs(lint&x){return x<0?x=-x,1:0;}
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint T,x,y;std::cin>>T>>x>>y;
lint sx=cabs(x),sy=cabs(y);
if(x==0&&y==0&&T==1||T<std::max(x,y)){
std::cout<<"NO"<<'\n';
return 0;
}
lint sxy=x>y?std::swap(x,y),1:0;
std::vector<std::string>ans;
auto mvchar=[&](char c){
if(c=='<')x++;
if(c=='>')x--;
if(c=='v')y++;
if(c=='^')y--;
};
auto mvstr=[&](std::string const&s){
T--;
for(char c:s)mvchar(c);
ans.push_back(s);
};
while(T){
using vec=std::vector<std::string>;
vec v=(T-std::max(x,y))%2
?(x?vec{"^",">"}:y?vec{"^<",">"}:vec{"^",">","v<"})
:(x?vec{"^>"}:y?vec{"^"}:vec{"^","v"});
assert(0<=x&&0<=y);
for(std::string&s:v)mvstr(s);
}
auto replace=[&](char&c,char c0,char c1){
if(c==c0)c=c1;
else if(c==c1)c=c0;
};
for(auto&&s:ans)for(char&c:s){
if(sx)replace(c,'<','>');
if(sy)replace(c,'v','^');
if(sxy){
replace(c,'^','>');
replace(c,'v','<');
}
}
std::cout<<"YES"<<'\n';
for(auto&&s:ans){
std::cout<<s<<'\n';
}
}
ngtkana