結果

問題 No.2251 Marking Grid
ユーザー bayashikobayashiko
提出日時 2023-03-07 21:59:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,868 bytes
コンパイル時間 5,420 ms
コンパイル使用メモリ 278,780 KB
実行使用メモリ 16,612 KB
最終ジャッジ日時 2023-10-18 05:38:56
合計ジャッジ時間 11,093 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 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 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
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 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
//#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define MINF (lint)(2e18)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define flc(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
//#define vec vector<lint>
#define nep(x) next_permutation(all(x))
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=3e5+5;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//vector<int> bucket[MAX_N/1000];
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
//typedef __int128_t llint;
#include<atcoder/all>
using namespace atcoder;

int main(void){
    int H,W;
    cin >> H >> W;
    lint A[H][W];
    rep(i,H) rep(j,W) cin >> A[i][j];
    /*lint naive_ans=0;
    rep(i,(1<<(H*W))){
        int M[H][W]={};
        lint maxi=0;
        rep(j,H) rep(k,W){
            if(i&(1<<(j*W+k))) M[j][k]=1,chmax(maxi,A[j][k]);
        }
        bool ok=true;
        rep(j,H-1) rep(k,W-1){
            int sum=M[j][k]+M[j+1][k]+M[j][k+1]+M[j+1][k+1];
            if(sum%2) ok=false;
        }
        if(ok) naive_ans+=maxi,naive_ans%=MOD;
    }
    cout << naive_ans << endl;*/
    lint ans=0;
    rep(i,(1<<H)) rep(j,(1<<W)){
        bool M[H][W]={};
        rep(k,H){
            if(i&(1<<k)){
                rep(l,W) M[k][l]^=1;
            }
        }
        rep(k,W){
            if(j&(1<<k)){
                rep(l,H) M[l][k]^=1;
            }
        }
        lint maxi=0;
        rep(k,H) rep(l,W) if(M[k][l]) chmax(maxi,A[k][l]);
        ans+=maxi;
    }
    cout << (ans*inv_mod(2,MOD))%MOD << endl;
    /*using mint=modint998244353;
    mint fast_ans=0;
    dsu uf(H+W);
    lint ufcomp=H+W;
    vector<pair<lint,plint>> masu;
    rep(i,H) rep(j,W) masu.push_back({A[i][j],{i,j}});
    sort(all(masu));
    reverse(all(masu));
    for(auto e:masu){
        lint nx=e.se.fi,ny=e.se.se;
        lint num=e.fi;
        if(uf.same(nx,H+ny)) continue;
        uf.merge(nx,H+ny);
        ufcomp--;
        mint add=num;
        add*=pow_mod(2,ufcomp-1,MOD);
        uf.merge(nx,H+ny);
        fast_ans+=add;
    }
    cout << fast_ans.val() << endl;*/
}
0