답안 #942368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942368 2024-03-10T14:11:23 Z djs100201 Vision Program (IOI19_vision) C++17
0 / 100
2 ms 2908 KB
#include<bits/stdc++.h>
#include "vision.h"
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ =2024+100, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353;
ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k;
ll gcd(ll x,ll y){
	if(!y)return x;
	return gcd(y,x%y);
}
int idx[n_][n_];
void construct_network(int H, int W, int K) {
	vector<int> Ns;
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)idx[i][j]=base++;
    //0 1 2 3 .. W-1
    //
    vector<int>N(H),M(W);
    for(int i=0;i<H;i++){
        N[i]=base++;
        for(int j=0;j<W;j++)Ns.push_back(W*i+j);
        add_or(Ns);
        Ns.clear();
    }
    for(int i=0;i<W;i++){
        M[i]=base++;
        for(int j=0;j<H;j++)Ns.push_back(idx[j][i]);
        add_or(Ns);
        Ns.clear();
    }
    vector<int>N2(9,-1),M2(9,-1),C(9,-1),res(9,-1);
    for(int i=0;i<9;i++){
        a=(1ll<<i);
        vector<int>T;
        for(int j=0;j+a<H;j++){
            T.push_back(base++);
            Ns={N[j],N[j+a]};
            add_and(Ns);
            Ns.clear();
        }
        if(T.empty())continue;
        N2[i]=base++;
        add_or(T);
    }
    for(int i=0;i<9;i++){
        a=(1ll<<i);
        vector<int>T;
        for(int j=0;j+a<W;j++){
            T.push_back(base++);
            Ns={M[j],M[j+a]};
            add_and(Ns);
            Ns.clear();
        }
        if(T.empty())continue;
        M2[i]=base++;
        add_or(T);
    }
    res[0]=base++;
    add_xor({N2[0],M2[0]});
    C[1]=base++;
    add_and({N2[0],M2[0]});
    for(int i=1;i<9;i++){
        if(N2[i]==-1 && M2[i]==-1){
            res[i]=C[i];
            break;
        }
        if(N2[i]==-1){
            res[i]=base++;
            add_xor({M2[i],C[i]});
            C[i+1]=base++;
            add_and({M2[i],C[i]});
        }
        else if(M2[i]==-1){
            res[i]=base++;
            add_xor({N2[i],C[i]});
            C[i+1]=base++;
            add_and({N2[i],C[i]});
        }
        else{
            res[i]=base++;
            add_xor({N2[i],M2[i],C[i]});
            a=base++;
            add_and({N2[i],C[i]});
            b=base++;
            add_and({M2[i],C[i]});
            c=base++;
            add_and({N2[i],M2[i]});
            C[i+1]=base++;
            add_or({(int)a,(int)b,(int)c});
        }
    }
    vector<int>fin;
    for(int i=0;i<9;i++){
        if(res[i]==-1)continue;
        a=(1<<i);
        if(!(K&a)){
            res[i]=base++;
            add_not(res[i]);
        }
        fin.push_back(res[i]);
    }
    add_and(fin);

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2908 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -