結果

問題 No.5002 stick xor
ユーザー sumorusumoru
提出日時 2018-05-26 13:28:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 1,000 ms
コード長 2,316 bytes
コンパイル時間 3,132 ms
実行使用メモリ 1,556 KB
スコア 40,353
最終ジャッジ日時 2018-05-26 13:28:40
ジャッジサーバーID
(参考情報)
judge6 /
純コード判定しない問題か言語
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
1,556 KB
testcase_01 AC 23 ms
1,556 KB
testcase_02 AC 24 ms
1,552 KB
testcase_03 AC 24 ms
1,552 KB
testcase_04 AC 23 ms
1,552 KB
testcase_05 AC 24 ms
1,556 KB
testcase_06 AC 23 ms
1,552 KB
testcase_07 AC 24 ms
1,556 KB
testcase_08 AC 24 ms
1,552 KB
testcase_09 AC 24 ms
1,556 KB
testcase_10 AC 24 ms
1,556 KB
testcase_11 AC 24 ms
1,552 KB
testcase_12 AC 27 ms
1,552 KB
testcase_13 AC 28 ms
1,552 KB
testcase_14 AC 37 ms
1,548 KB
testcase_15 AC 28 ms
1,556 KB
testcase_16 AC 26 ms
1,552 KB
testcase_17 AC 28 ms
1,552 KB
testcase_18 AC 25 ms
1,552 KB
testcase_19 AC 25 ms
1,552 KB
testcase_20 AC 40 ms
1,552 KB
testcase_21 AC 24 ms
1,552 KB
testcase_22 AC 27 ms
1,552 KB
testcase_23 AC 24 ms
1,556 KB
testcase_24 AC 29 ms
1,552 KB
testcase_25 AC 25 ms
1,556 KB
testcase_26 AC 25 ms
1,552 KB
testcase_27 AC 34 ms
1,552 KB
testcase_28 AC 37 ms
1,552 KB
testcase_29 AC 28 ms
1,552 KB
testcase_30 AC 26 ms
1,552 KB
testcase_31 AC 25 ms
1,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

struct Ans {
    int a, b, c, d;
    friend ostream& operator << (ostream& out, Ans& e) {
        return out << e.a + 1 << ' ' << e.b + 1 << ' ' << e.c + 1 << ' ' << e.d + 1;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> ls(k); cin >> ls;
    vector<string> as(n); cin >> as;
    for(auto& a : as){ for(auto& e : a){ e -= '0'; } }
    vector<Ans> ans(k);
    for(int i = 0; i < k; i++){
        int maxi = -1;
        for(int y = 0; y < n; y++){
            for(int x = 0; x < n - ls[i]; x++){
                int cnt = 0;
                for(int j = 0; j < ls[i]; j++){
                    cnt += as[y][x + j];
                }
                if(maxi < cnt){
                    maxi = cnt;
                    ans[i] = {y, x, y, x + ls[i] - 1};
                }
            }
        }
        for(int y = 0; y < n - ls[i]; y++){
            for(int x = 0; x < n; x++){
                int cnt = 0;
                for(int j = 0; j < ls[i]; j++){
                    cnt += as[y + j][x];
                }
                if(maxi < cnt){
                    maxi = cnt;
                    ans[i] = {y, x, y + ls[i] - 1, x};
                }
            }
        }
        for(int y = ans[i].a; y <= ans[i].c; y++){
            for(int x = ans[i].b; x <= ans[i].d; x++){
                as[y][x] = !as[y][x];
            }
        }
    }
    for(auto& e : ans){
        cout << e << '\n';
    }
}
0