結果

問題 No.3430 Flip the Grid
コンテスト
ユーザー mentos_grape
提出日時 2026-01-11 14:22:14
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 296 ms / 2,000 ms
コード長 1,257 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,535 ms
コンパイル使用メモリ 311,708 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2026-01-11 14:22:23
合計ジャッジ時間 9,141 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const ll MOD = 998244353;
const double INFD = 1.0E10;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};
//const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using Pair = pair<ll, ll>;
using Graph = vector<vector<ll>>;
using mint = atcoder::modint998244353;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    
    int h, w; cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    
    
    int ans1 = 0;
    for (int i = 0; i < h; i++){
        int x = 0;
        for (int j = 0; j < w; j++){
            x ^= a[i][j];
        }
        ans1 += x;
    }
    
    int ans2 = 0;
    for (int i = 0; i < w; i++){
        int x = 0;
        for (int j = 0; j < h; j++){
            x ^= a[j][i];
        }
        ans2 += x;
    }
    
    
    cout << max(ans1, ans2) << endl;
    
    
    
    
    return 0;
}
0