結果

問題 No.1004 サイコロの実装 (2)
ユーザー hanachanXhanachanX
提出日時 2020-04-12 15:08:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,366 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 181,044 KB
実行使用メモリ 814,904 KB
最終ジャッジ日時 2023-10-22 01:17:05
合計ジャッジ時間 6,546 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 MLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:40:37: warning: 'j' may be used uninitialized [-Wmaybe-uninitialized]
   40 |         if((x[i]%6+1)%2 != 0) ++ao[j]; //white
      |                                 ~~~~^
main.cpp:34:13: note: 'j' was declared here
   34 |     int i , j;
      |             ^

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;
template<class T> using V = vector<T>;
using I = int;
using VI = V<I>;
const int INF = 2e9;
const int64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T& a, T b){if(a>b){a=b; return true;} return false;}
template <class T> inline bool chmax(T& a, T b){if(a<b){a=b; return true;} return false;}

int main(){
    uint64 a , b , x0 ,n;
    cin >> a >> b >> x0 >> n;
    if( n == 0) { cout << 0 << " " << 0 << endl; return 0; }
    vector<uint64> x(n);
    x[0] = x0;
    for(int i = 1; i < n ; ++i){
        x[i]=(a*x[i-1]+b)%(int)pow(2,32); 
    }
    uint64 ta[2]={0};
    uint64 ao[2]={0};
    int i , j;
    for(i=2 ; i <= n ; i+=2){
        if((x[i]%6+1)%2 != 0) ++ta[0];
        else ++ta[1]; 
    }
    for(i=2 ; i <=n ; i+=2){
        if((x[i]%6+1)%2 != 0) ++ao[j]; //white
        else ++ao[1]; //black
    }
    chmin(ta[0] , ta[1]);
    chmin(ao[0] , ao[1]);

    cout << ta[0] << " " << ao[0] << endl;

}
0