이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "vision.h"
#define F first
#define S second
#define PB push_back
#define sz(s) (int(s.size()))
#define bit(n, k) (((n)>>(k))&1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int LOG = 10; // kam tare!
const int maxn = 210;
int counter;
vector<int> operator + (vector<int> a, vector<int> b){
vector<int> ans;
int ext = -1;
for(int i = 0; i < max(sz(a), sz(b)); i++){
vector<int> sm;
if(ext != -1)
sm.PB(ext);
if(i < sz(a))
sm.PB(a[i]);
if(i < sz(b))
sm.PB(b[i]);
ans.PB(counter++);
add_xor(sm);
vector<int> toOr;
for(int w = 0; w < sz(sm); w++)
for(int w2 = w+1; w2 < sz(sm); w2++){
vector<int> chert = {sm[w], sm[w2]};
toOr.PB(counter++);
add_and(chert);
}
if(toOr.empty()){
ext = -1;
}
else{
ext = counter++;
add_or(toOr);
}
}
if(ext != -1)
ans.PB(ext);
while(sz(ans) > LOG)
ans.pop_back();
return ans;
}
int rows[maxn], cols[maxn];
void construct_network(int H, int W, int K){
/*
vector<int> Ns;
Ns = {0, 1};
int a = add_and(Ns);
Ns = {0, a};
int b = add_or(Ns);
Ns = {0, 1, b};
int c = add_xor(Ns);
add_not(c);*/
auto to = [&](int x, int y){
return x * W + y;
};
counter = H * W;
for(int i = 0; i < H; i++){
vector<int> chert;
for(int j = 0; j < W; j++)
chert.PB(to(i, j));
rows[i] = counter++;
add_xor(chert);
}
for(int j = 0; j < W; j++){
vector<int> chert;
for(int i = 0; i < H; i++)
chert.PB(to(i, j));
cols[j] = counter++;
add_xor(chert);
}
vector<int> toSum;
int Nw = -1;
for(int i = 0; i < H; i++){
if(Nw == -1){
Nw = rows[i];
}
else{
vector<int> chert = {Nw, rows[i]};
Nw = counter++;
add_xor(chert);
}
toSum.PB(Nw);
}
Nw = -1;
for(int j = 0; j < W; j++){
if(Nw == -1){
Nw = cols[j];
}
else{
vector<int> chert = {Nw, cols[j]};
Nw = counter++;
add_xor(chert);
}
toSum.PB(Nw);
}
vector<int> sum;
for(int id : toSum){
vector<int> vec = {id};
sum = sum + vec;
}
bool bad = 0;
for(int i = 0; i < LOG; i++){
if(bit(K, i)){
bad|= sz(sum) <= i;
}
else if(sz(sum) > i){
add_not(sum[i]);
sum[i] = counter++;
}
}
add_and(sum);
counter++;
if(bad){
add_not(0);
counter++;
vector<int> chert = {0, counter-1, counter-2};
add_and(chert);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |