結果
| 問題 | No.5002 stick xor |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-25 22:56:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 1,000 ms |
| コード長 | 3,411 bytes |
| 記録 | |
| コンパイル時間 | 2,127 ms |
| 実行使用メモリ | 1,588 KB |
| スコア | 14,589 |
| 最終ジャッジ日時 | 2018-05-25 22:56:10 |
|
ジャッジサーバーID (参考情報) |
judge8 / |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
struct range{
int y1, x1, y2, x2;
};
inline int one(int condition){
if(condition){
return 1;
}else{
return 1;
}
}
void range_output(range ans_range){
cout << ans_range.y1 + 1 << " " << ans_range.x1 + 1 << " " << ans_range.y2 << " " << ans_range.x2 << endl;
}
int main(){
int N, K;
cin >> N >> K;
int L_array[K];
map<int, int> L;
for(int i = 0; i < K; i++){
cin >> L_array[i];
L[L_array[i]]++;
}
int space[N][N];
for(int i = 0; i < N; i++){
string space_string;
cin >> space_string;
for(int j = 0; j < N; j++){
space[i][j] = (space_string[j] == '1');
}
}
map<int, vector<range>> ranges;
for(int i = 0; i < N; i++){
int continuity = 0;
for(int j = 0; j < N; j++){
if(space[i][j]){
continuity++;
}else if(continuity){
ranges[continuity].push_back({i, j - continuity, i + 1, j});
continuity = 0;
}
}
}
map<int, vector<range>> ans;
for(int i = 1; i <= 25; i++){
if(L[i] > ranges[i].size()){
for(int j = 0; j < ranges[i].size(); j++){
ans[i].push_back(ranges[i][j]);
}
for(int j = int(ranges[i].size()); j < L[i]; j++){
ans[i].push_back({0, 0, 1, i});
}
}else{
for(int j = 0; j < L[i]; j++){
ans[i].push_back(ranges[i][j]);
}
}
}
for(int i = 0; i < K; i++){
range_output(ans[L_array[i]].back());
ans[L_array[i]].pop_back();
}
}