結果
| 問題 | No.5002 stick xor | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-05-26 13:28:35 | 
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.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 / | 
| 純コード判定しない問題か言語 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 32 | 
ソースコード
#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';
    }
}
            
            
            
        