結果

問題 No.2082 AND OR XOR
ユーザー StstoneStstone
提出日時 2022-10-18 15:32:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 2,492 bytes
コンパイル時間 2,357 ms
コンパイル使用メモリ 206,664 KB
実行使用メモリ 4,544 KB
最終ジャッジ日時 2023-09-11 08:51:55
合計ジャッジ時間 5,315 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,360 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 17 ms
4,376 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 15 ms
4,492 KB
testcase_07 AC 12 ms
4,376 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 11 ms
4,376 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 20 ms
4,452 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 9 ms
4,380 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 16 ms
4,380 KB
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 17 ms
4,380 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 14 ms
4,380 KB
testcase_22 AC 12 ms
4,380 KB
testcase_23 AC 18 ms
4,428 KB
testcase_24 AC 18 ms
4,400 KB
testcase_25 AC 17 ms
4,504 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 10 ms
4,380 KB
testcase_28 AC 19 ms
4,544 KB
testcase_29 AC 20 ms
4,532 KB
testcase_30 AC 19 ms
4,484 KB
testcase_31 AC 20 ms
4,484 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:26:18: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                  ^
main.cpp:26:20: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                    ^
main.cpp:26:22: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                      ^
main.cpp:26:24: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                        ^
main.cpp:26:28: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                            ^
main.cpp:26:30: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                              ^~
main.cpp:26:33: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                                 ^~
main.cpp:26:36: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                                    ^
main.cpp:26:38: 警告: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   26 |     register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
      |                                      ^
main.cpp:26:40: 警告: ISO C++17 does not al

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define double long double
#define pii pair<int,int>
#define F first
#define S second
#define no_more_love ios_base::sync_with_stdio(0),cin.tie(0)
#define pb push_back
//#define P pair<int,int>
using namespace std;
const int maxn=5005,MOD=998244353;
int ar[5][5];
bool vis[maxn];
int cnt[maxn];
int ar2[maxn];
map<int,int>mp;
vector<int>v[maxn],v2,v3;
int dp[maxn][5][5],dp2[maxn],n,m;//dp[i][j][k]代表第i個位置由前為j,由後應為k
set<int>s,ss;
//queue<int>q;
deque<int>dq;

signed main()
{
    no_more_love;
    register int t,i,j,a=0,b,a1,b1,k,d,cnt2,flag,flag2,a2,c,x,y,z;
    t=1;
    string s1,s2;
    char cccc,ccccc;
    //cin>>t;
    while(t--){
        cin>>n>>a>>b>>c;
        for(i=0;i<4;i++){
            for(j=0;j<4;j++){
                ar[i][j]=(a*(i&j)+b*(i|j)+c*(i^j))%4;
            }
        }
        int ans=0;
        for(x=0;x<=3;x++){
            for(i=0;i<=n;i++){
                for(j=0;j<=3;j++){
                    for(k=0;k<=3;k++)dp[i][j][k]=0;
                }
            }
            for(i=0;i<=3;i++){
                for(j=0;j<=3;j++){
                    if(ar[i][j]==x)dp[1][i][j]+=1;
                    //assert(ar[i][j]==ar[j][i]);
                }
            }
            /*dp[1][1][ar[1][x]]=1;
            dp[1][2][ar[2][x]]=1;
            dp[1][3][ar[3][x]]=1;
            dp[1][0][ar[0][x]]=1;*/
            for(i=2;i<=n-1;i++){
                for(j=0;j<=3;j++){
                    for(y=0;y<=3;y++){
                        for(z=0;z<=3;z++){
                            for(a1=0;a1<=3;a1++){
                                if(ar[y][a1]==j){
                                    for(k=0;k<=3;k++){
                                        if(ar[k][a1]==z)dp[i][j][k]+=dp[i-1][y][z];
                                        dp[i][j][k]%=MOD;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            for(i=0;i<=3;i++){
                for(j=0;j<=3;j++){
                    if(ar[i][j]==x){
                        ans+=dp[n-1][i][j];
                    }
                }
            }
            /*for(i=0;i<=3;i++){
                if(ar[i][x]==x){
                    ans+=dp[n][x][i];
                }
            }*/
            //ans+=dp[n][x][0];
            ans%=MOD;
        }
        cout<<ans<<'\n';
    }
    return 0;
}
/*
*/
0