結果

問題 No.2824 Lights Up! (Grid Edition)
ユーザー NachiaNachia
提出日時 2024-07-26 22:28:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,216 bytes
コンパイル時間 1,482 ms
コンパイル使用メモリ 115,064 KB
実行使用メモリ 37,632 KB
最終ジャッジ日時 2024-07-26 22:28:26
合計ジャッジ時間 19,479 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 333 ms
30,848 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 330 ms
30,976 KB
testcase_12 WA -
testcase_13 AC 881 ms
30,848 KB
testcase_14 WA -
testcase_15 AC 768 ms
36,224 KB
testcase_16 WA -
testcase_17 AC 821 ms
30,976 KB
testcase_18 WA -
testcase_19 AC 960 ms
37,632 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 267 ms
25,728 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 18 ms
6,944 KB
testcase_26 WA -
testcase_27 AC 670 ms
28,928 KB
testcase_28 WA -
testcase_29 AC 44 ms
6,940 KB
testcase_30 WA -
testcase_31 AC 2 ms
6,944 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
6,944 KB
testcase_36 WA -
testcase_37 AC 3 ms
6,940 KB
testcase_38 WA -
testcase_39 AC 2 ms
6,944 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 2 ms
6,944 KB
testcase_44 WA -
testcase_45 AC 2 ms
6,944 KB
testcase_46 WA -
testcase_47 AC 2 ms
6,940 KB
testcase_48 AC 2 ms
6,940 KB
testcase_49 AC 2 ms
6,944 KB
testcase_50 WA -
testcase_51 AC 2 ms
6,944 KB
testcase_52 AC 2 ms
6,940 KB
testcase_53 AC 2 ms
6,944 KB
testcase_54 WA -
testcase_55 AC 2 ms
6,940 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 2 ms
6,944 KB
testcase_60 WA -
testcase_61 AC 2 ms
6,940 KB
testcase_62 WA -
testcase_63 AC 1 ms
6,944 KB
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 AC 2 ms
6,940 KB
testcase_68 AC 2 ms
6,944 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 2 ms
6,944 KB
testcase_84 AC 2 ms
6,940 KB
testcase_85 AC 2 ms
6,940 KB
testcase_86 AC 2 ms
6,940 KB
testcase_87 AC 2 ms
6,940 KB
testcase_88 WA -
testcase_89 WA -
testcase_90 AC 2 ms
6,940 KB
testcase_91 AC 2 ms
6,940 KB
testcase_92 AC 2 ms
6,944 KB
testcase_93 AC 2 ms
6,944 KB
testcase_94 WA -
testcase_95 AC 2 ms
6,944 KB
testcase_96 AC 2 ms
6,944 KB
testcase_97 AC 2 ms
6,940 KB
testcase_98 AC 2 ms
6,944 KB
testcase_99 AC 2 ms
6,944 KB
testcase_100 AC 2 ms
6,940 KB
testcase_101 AC 2 ms
6,944 KB
testcase_102 AC 2 ms
6,944 KB
testcase_103 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <array>
#include <cmath>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
#define repr(i,n) for(int i=int(n)-1; i>=0; i--)
const i64 INF = 1001001001001001001;
const char* yn(bool x){ return x ? "Yes" : "No"; }
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
template<typename A> using nega_queue = std::priority_queue<A,std::vector<A>,std::greater<A>>;
template<class R> auto ComparingBy(R f){ return [g=std::move(f)](auto l, auto r) -> bool { return g(l) < g(r); }; }
#include <atcoder/modint>
#include <set>
using Modint = atcoder::static_modint<998244353>;
using namespace std;

void testcase(){
    int N; cin >> N;
    set<pair<int,int>> ans;
    vector<vector<int>> Q(N, vector<int>(N));
    rep(x,N){
        string s; cin >> s;
        rep(y,N) Q[x][y] = (s[y] == '#' ? 1 : 0);
    }
   // rep(x,N){ rep(y,N){ cout << Q[x][y]; } cout << endl; }
    auto ope = [&](int x, int y){
        Q[x][y] ^= 1;
        Q[x == 0 ? N - 1 : x - 1][y] ^= 1;
        Q[x][y == 0 ? N - 1 : y - 1] ^= 1;
        Q[x == 0 ? N - 1 : x - 1][y == 0 ? N - 1 : y - 1] ^= 1;
    };
    auto mov = [&](int x, int y){
        ope(x, y);
        ope(x, 0);
        ope(0, y);
        if(ans.count({x,y})) ans.erase({x,y}); else ans.insert({x,y});
    };
    for(int x=1; x<N-1; x++) for(int y=1; y<N-1; y++) if(Q[x][y]) mov(x+1, y+1);
    //rep(x,N){ rep(y,N){ cout << Q[x][y]; } cout << endl; }
    //vector<nachia::Bitset> bs(N*4 - 4, nachia::Bitset(N*2-1));
    if(N % 2 == 1){
        for(int i=N-2; i>=0; i--) if(Q[i][0]){
            for(int j=1; j<N; j++) mov(i,j);
        }
        for(int i=N-2; i>=0; i--) if(Q[0][i]){
            for(int j=1; j<N; j++) mov(j,i);
        }
    }
    if(Q[0][0]) mov(0,0);
    cout << ans.size() << '\n';
    for(auto [x,y] : ans) cout << x << ' ' << y << '\n';
}

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    testcase();
    return 0;
}
0