結果

問題 No.675 ドットちゃんたち
ユーザー Layla
提出日時 2018-06-13 23:47:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 1,294 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 23,808 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-06-30 14:15:01
合計ジャッジ時間 4,556 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 TLE * 1 -- * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |     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[j][0]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         scanf("%d", &command[j][1]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

typedef struct dot {
    int x;
    int y;
} 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 i = 0; i < dot_num; ++i) {
        dots[i].x = initial_x;
        dots[i].y = initial_y;
    }

    for (int j = 0; j < dot_num; ++j) {
        scanf("%d", &command[j][0]);
        if (command[j][0] == 3) {
            continue;
        }
        scanf("%d", &command[j][1]);
    }

    for (int k = 0; k < dot_num; ++k) {
        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;
                case 3: {
                    int temp = dots[k].x;
                    dots[k].x = dots[k].y;
                    dots[k].y = -temp;
                    break;
                }
                default:
                    printf("invalid value\n");
                    break;
            }
        }
    }

    for (int l = 0; l < dot_num; ++l) {
        printf("%d %d\n", dots[l].x, dots[l].y);
    }


    return 0;
}
0