제출 #1338200

#제출 시각아이디문제언어결과실행 시간메모리
1338200karn7777Vision Program (IOI19_vision)C++20
100 / 100
33 ms5928 KiB
#include<utility>
#include<map>
#include "vision.h"
using namespace std;
int m,n;
int helper(int i,int j){
    return i*m+j;
}
void construct_network(int H, int W, int k){
    m=W;
    n=H;
    map<int,vector<int>> lcol,rcol;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            lcol[i+j].push_back(helper(i,j));
            rcol[i-j].push_back(helper(i,j));
        }
    }
    vector<int> lvec,rvec;
    vector<int> lxor,rxor;
    for(auto x:lcol){
        lvec.push_back(add_or(x.second));
        lxor.push_back(add_xor(x.second));
    }
    for(auto x:rcol){
        rvec.push_back(add_or(x.second));
        rxor.push_back(add_xor(x.second));
    }
    int A,B,C,D;
    vector<int> va,vb,vc,vd;
    // l need to put k-1 on l to A , k on B , r with C then D proceedingly
    //A is the k-1 on l
    for(int i=0;i+k-1<lvec.size();i++){
        vector<int> tempor,tempxor;
        for(int j=i;j<=i+k-1;j++){
            tempor.push_back(lvec[j]);
            tempxor.push_back(lxor[j]);
        }
        int e=add_or(tempor),f=add_xor(tempxor);
        va.push_back(add_and({add_not({f}),e}));
    }

    for(int i=0;i+k<lvec.size();i++){
        vector<int> tempor,tempxor;
        for(int j=i;j<=i+k;j++){
            tempor.push_back(lvec[j]);
            tempxor.push_back(lxor[j]);
        }
        int e=add_or(tempor),f=add_xor(tempxor);
        vb.push_back(add_and({add_not({f}),e}));
    }
    for(int i=0;i+k-1<rvec.size();i++){
        vector<int> tempor,tempxor;
        for(int j=i;j<=i+k-1;j++){
            tempor.push_back(rvec[j]);
            tempxor.push_back(rxor[j]);
        }
        int e=add_or(tempor),f=add_xor(tempxor);
        vc.push_back(add_and({add_not({f}),e}));
    }

    for(int i=0;i+k<rvec.size();i++){
        vector<int> tempor,tempxor;
        for(int j=i;j<=i+k;j++){
            tempor.push_back(rvec[j]);
            tempxor.push_back(rxor[j]);
        }
        int e=add_or(tempor),f=add_xor(tempxor);
        vd.push_back(add_and({add_not({f}),e}));
    }
    //below is correct when A=k-1 B=k C=k-1 D=k
    A=add_or(va);
    B=add_or(vb);
    C=add_or(vc);
    D=add_or(vd);
    swap(A,B);
    swap(C,D);
    add_or({add_and({A,add_not(B),C}),add_and({A,B,C,add_not(D)})});
}
//240
/*
0,1,2,3
4,5,6,7
8,9,10,11
12,13,14,15
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...