結果
| 問題 |
No.675 ドットちゃんたち
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-14 00:48:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,623 bytes |
| コンパイル時間 | 138 ms |
| コンパイル使用メモリ | 23,936 KB |
| 実行使用メモリ | 13,884 KB |
| 最終ジャッジ日時 | 2024-06-30 14:15:31 |
| 合計ジャッジ時間 | 3,828 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 2 TLE * 1 -- * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d%d%d", &dot_num, &initial_x, &initial_y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d", &command[k][0]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d", &command[k][1]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
typedef struct dot {
int x;
int y;
int r_num;
} Dot;
int main() {
int dot_num = 0;
int initial_x, initial_y;
scanf("%d%d%d", &dot_num, &initial_x, &initial_y);
Dot dots[dot_num];
int command[dot_num][2];
for (int k = 0; k < dot_num; ++k) {
dots[k].x = initial_x;
dots[k].y = initial_y;
dots[k].r_num = 0;
scanf("%d", &command[k][0]);
if (command[k][0] == 3) {
for (int i = k; i < dot_num; ++i) {
dots[k].r_num++;
}
continue;
}
scanf("%d", &command[k][1]);
for (int i = k; i < dot_num; ++i) {
switch (command[i][0]) {
case 1:
dots[k].x += command[i][1];
break;
case 2:
dots[k].y += command[i][1];
break;
}
}
}
for (int k = 0; k < dot_num; ++k) {
switch (dots[k].r_num % 4) {
case 1: {
int temp = dots[k].x;
dots[k].x = dots[k].y;
dots[k].y = -temp;
break;
}
case 2: {
dots[k].x = -dots[k].x;
dots[k].y = -dots[k].y;
break;
}
case 3: {
int temp = dots[k].x;
dots[k].x = -dots[k].y;
dots[k].y = temp;
break;
}
}
}
for (int l = 0; l < dot_num; ++l) {
printf("%d %d\n", dots[l].x, dots[l].y);
}
return 0;
}