結果
問題 | No.5002 stick xor |
ユーザー | ミドリムシ |
提出日時 | 2018-05-25 22:56:06 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.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 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
1,584 KB |
testcase_01 | AC | 5 ms
1,584 KB |
testcase_02 | AC | 4 ms
1,580 KB |
testcase_03 | AC | 5 ms
1,588 KB |
testcase_04 | AC | 5 ms
1,584 KB |
testcase_05 | AC | 5 ms
1,588 KB |
testcase_06 | AC | 6 ms
1,588 KB |
testcase_07 | AC | 5 ms
1,584 KB |
testcase_08 | AC | 4 ms
1,580 KB |
testcase_09 | AC | 5 ms
1,584 KB |
testcase_10 | AC | 4 ms
1,584 KB |
testcase_11 | AC | 5 ms
1,588 KB |
testcase_12 | AC | 5 ms
1,584 KB |
testcase_13 | AC | 4 ms
1,588 KB |
testcase_14 | AC | 5 ms
1,588 KB |
testcase_15 | AC | 5 ms
1,584 KB |
testcase_16 | AC | 4 ms
1,588 KB |
testcase_17 | AC | 5 ms
1,584 KB |
testcase_18 | AC | 4 ms
1,584 KB |
testcase_19 | AC | 4 ms
1,584 KB |
testcase_20 | AC | 5 ms
1,584 KB |
testcase_21 | AC | 5 ms
1,584 KB |
testcase_22 | AC | 4 ms
1,584 KB |
testcase_23 | AC | 5 ms
1,584 KB |
testcase_24 | AC | 4 ms
1,584 KB |
testcase_25 | AC | 5 ms
1,584 KB |
testcase_26 | AC | 4 ms
1,584 KB |
testcase_27 | AC | 5 ms
1,584 KB |
testcase_28 | AC | 4 ms
1,576 KB |
testcase_29 | AC | 4 ms
1,584 KB |
testcase_30 | AC | 5 ms
1,584 KB |
testcase_31 | AC | 5 ms
1,584 KB |
ソースコード
#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(); } }