結果
問題 | No.2228 Creeping Ghost |
ユーザー |
|
提出日時 | 2023-03-03 14:46:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 1,287 bytes |
コンパイル時間 | 708 ms |
コンパイル使用メモリ | 87,232 KB |
最終ジャッジ日時 | 2025-02-11 01:26:11 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h>#include<string.h>#include<stdlib.h>#include <map>#include <vector>#include <queue>#include <deque>#include <set>#include <stack>#include <algorithm>#include <array>#include <unordered_set>#include <unordered_map>#include <string>using namespace std;bool rcmp(int a, int b) { return a>b; }typedef long long LL;char ob[1000004];void assert(int *p) { *p=0; }int main() {int n, i, j, k;const char* p[] = {"RLRD","DUDL","LRLU","UDUR",};scanf("%d", &n);if (n<4) {for (i=0; i<n; i++) ob[i]='D';} else {ob[0]='R'; ob[1]='L'; ob[2]='R'; ob[3]='D';for (i=4; i<n; ) {for (k=0; k<4&&i<n; k++) {for (j=0; j<4&&i<n; j++) {ob[i++]=p[k][j];}}}}ob[n]=0;// checkint px=0, py=0, cx=0, cy=0, x=-1, y=-1;for (i=0; i<n; i++) {if (ob[i]=='R') cy++;else if (ob[i]=='L') cy--;else if (ob[i]=='U') cx--;else cx++;if (cx<0||cx>4||cy<0||cy>4) assert(0);if ((i%4)==3) {x=px; y=py;px=cx; py=cy;}if (cx==x||cy==y) assert(0);}printf("%s\n", ob);return 0;}