結果

問題 No.619 CardShuffle
ユーザー mitukou1109jpmitukou1109jp
提出日時 2018-03-28 19:08:08
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,500 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 29,820 KB
実行使用メモリ 811,744 KB
最終ジャッジ日時 2023-09-07 19:27:55
合計ジャッジ時間 3,335 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 WA -
testcase_16 MLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

int main(){
    int N = 0;
    scanf("%d%*c", &N);
    char* C = (char*)malloc((sizeof(char))*N);
    int i;
    for(i=0;i<N;i++){
        scanf("%c%*c", &C[i]);
    }
    int Q = 0;
    scanf("%d%*[^\n]%*c", &Q);
    char* T = (char*)malloc((sizeof(char))*Q);
    int** XY = (int**)malloc((sizeof(int*))*Q);
    for(i=0;i<Q;i++){
        XY[i] = (int*)malloc((sizeof(int))*2);
    }
    for(i=0;i<Q;i++){
        getchar();
        scanf("%c%d%d%*[^\n]%*c", &T[i], &XY[i][0], &XY[i][1]);
    }

    for(i=0;i<Q;i++){
        if(T[i] == '!'){
            int x = XY[i][0] - 1;
            int y = XY[i][1] - 1;
            char Cx = C[x];
            char Cy = C[y];
            C[x] = Cy;
            C[y] = Cx;
        } else {
            long res = 0;
            long* num = (long*)malloc((sizeof(long))*N);
            int j;
            int x = XY[i][0] - 1;
            int y = XY[i][1] - 1;
            for(j=x;j<y+1;j=j+2){
                num[j] = C[j] - '0';
            }
            for(j=x+1;j<y;j=j+2){
                if(C[j] == '*'){
                    long p = num[j-1] * num[j+1];
                    num[j-1] = 0;
                    num[j+1] = p;
                }
            }
            for(j=x;j<y+1;j=j+2){
                res += num[j];
            }
            res %= (1000000000L + 7);
            printf("%ld\n", res);
        }
    }
    return 0;
}
0