# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894318 | 2023-12-28T05:24:54 Z | KaleemRazaSyed | Vision Program (IOI19_vision) | C++17 | 7 ms | 2000 KB |
#include<bits/stdc++.h> using namespace std; int add_and(vector<int> Ns); int add_or(vector<int> Ns); int add_xor(vector<int> Ns); int add_not(int N); // Robot Memory : // H * W|---cnt1---|---cnt2---|---cnt3---|---cnt4---|---cnt3---|---cnt4---|---cnt5---|---cnt6---|---2---|---2---|---1---|---1---|---1---| // grid |d1..or..d1|d2..or..d2|or1....or1|or2....or2|xor1..xor1|xor2..xor2|&1......&1|&2......&2|xor.xor|or..xor|&orxor.|..orr..|&orrxor| void construct_network(int H, int W, int K) { vector<pair<int,int> > d1, d2; for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) { d1.push_back({i + j, i * W + j}); d2.push_back({i - j, i * W + j}); } sort(d1.begin(), d1.end()); sort(d2.begin(), d2.end()); int cnt1 = 0, cnt2 = 0; vector<int> q; for(int i = 0; i < d1.size(); i++) { if(q.size() and d1[i-1].first != d1[i].first) { cnt1++; add_or(q); q.clear(); } q.push_back(d1[i].second); } cnt1++; add_or(q); q.clear(); for(int i = 0; i < d2.size(); i++) { if(q.size() and d2[i-1].first != d2[i].first) { cnt2++; add_or(q); q.clear(); } q.push_back(d2[i].second); } cnt2++; add_or(q); q.clear(); vector<int> D; // or int cnt3 = 1; for(int i = 0; i <= K; i++) D.push_back(H * W + i); for(int k = K + 1; k < cnt1; k++) { cnt3++; add_or(D); D.erase(D.begin()); D.push_back(H * W + k); } add_or(D); D.clear(); for(int i = 0; i <= K; i++) D.push_back(H * W + cnt1 + i); int cnt4 = 1; for(int k = K + 1; k < cnt2; k++) { cnt4++; add_or(D); D.erase(D.begin()); D.push_back(H * W + k + cnt1); } add_or(D); D.clear(); // xor for(int i = 0; i <= K; i++) D.push_back(H * W + i); for(int k = K + 1; k < cnt1; k++) { D.push_back(H * W + cnt1 + cnt2 + k - K); add_xor(D); D.pop_back(); D.erase(D.begin()); D.push_back(H * W + k); } D.push_back(H * W + cnt1 + cnt2 + cnt1 - K); add_xor(D); D.clear(); for(int i = 0; i <= K; i++) D.push_back(H * W + cnt1 + i); for(int k = K + 1; k < cnt2; k++) { D.push_back(H * W + cnt1 + cnt2 + cnt3 + k - K); add_xor(D); D.pop_back(); D.erase(D.begin()); D.push_back(H * W + k + cnt1); } D.push_back(H * W + cnt1 + cnt2 + cnt3 + cnt2 - K); add_xor(D); D.clear(); int cnt5 = 0; for(int i = 0; i < (int)d1.size() - K; i ++) { cnt5++; add_and({H * W + cnt1 + cnt2 + i, H * W + cnt1 + cnt2 + i + K}); } int cnt6 = 0; for(int i = 0; i < (int)d2.size() - K; i++) { cnt6++; add_and({H * W + cnt1 + cnt2 + cnt3 + i, H * W + cnt1 + cnt2 + cnt3 + i + K}); } vector<int> Xors; for(int i = 0; i < cnt3; i++) Xors.push_back(H * W + cnt1 + cnt2 + i); add_xor(Xors); Xors.clear(); for(int i = 0; i < cnt4; i++) Xors.push_back(H * W + cnt1 + cnt2 + cnt3 + i); add_xor(Xors); D.clear(); for(int i = 0; i < cnt3; i++) D.push_back({H * W + cnt1 + cnt2 + cnt3 + cnt4 + i}); D.push_back(H * W + cnt1 + cnt2 + cnt3 + cnt4 + cnt3 + cnt4 + cnt5 + cnt6); add_or(D); D.clear(); for(int i = 0; i < cnt4; i++) D.push_back({H * W + cnt1 + cnt2 + cnt3 + cnt4 + cnt3 + i}); D.push_back(H * W + cnt1 + cnt2 + cnt3 + cnt4 + cnt3 + cnt4 + cnt5 + cnt6 + 1); add_or(D); add_and({H * W + cnt1 + cnt2 + cnt3 + cnt4 + cnt3 + cnt4 + cnt5 + cnt6 + 2, H * W + cnt1 + cnt2 + cnt3 + cnt4 + cnt3 + cnt4 + cnt5 + cnt6 + 3}); D.clear(); for(int i = 0; i < cnt5; i++) D.push_back(H * W + cnt1 + cnt2 + cnt3 + cnt4 + cnt3 + cnt4 + i); for(int i = 0; i < cnt6; i++) D.push_back(H * W + cnt1 + cnt2 + cnt3 + cnt4 + cnt3 + cnt4 + cnt5 + i); add_or(D); int cnt = H * W + cnt1 + cnt2 + cnt3 + cnt4 + cnt3 + cnt4 + cnt5 + cnt6 + 4; add_and({cnt, cnt + 1}); //cout << H * W << ' ' << cnt1 << ' ' << cnt2 << ' ' << cnt3 << ' ' << cnt4 << ' ' << cnt3 << ' ' << cnt4 << ' ' << cnt5 << ' ' << cnt6 << ' ' << 4 << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | on inputs (0, 0), (0, 2), expected 0, but computed 1 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 2000 KB | WA in grader: Too many instructions |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 | Halted | 0 ms | 0 KB | - |