Submission #1042357

#TimeUsernameProblemLanguageResultExecution timeMemory
1042357HD1Vision Program (IOI19_vision)C++14
52 / 100
1 ms360 KiB
#include "vision.h"
#include<bits/stdc++.h>
#define sz(x) ll(x.size())
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const ll MAX=1e6;
int n, m, k;
vector<int>c, z, f, ans;
vector<int>s, p, q;
int dist(int a, int b, int i, int j){
    return abs(a-i)+abs(b-j);
}
void color(){
    if(n==1){
        int aux=k;
        for(int j=0; j<m; j++){
            if(aux>=m)break;
            q.pb(j);
            q.pb(aux);
            s.pb(add_and(q));
            q.pop_back();
            q.pop_back();
            aux++;
        }
    }
    else{
        int aux=k;
        for(int i=0; i<n; i++){
            if(aux>=n)break;
            q.pb(i);
            q.pb(aux);
            s.pb(add_and(q));
            q.pop_back();
            q.pop_back();
            aux++;
        }
    }
    add_or(s);
    return;
}
void looks(int dist_c, int dist_f){
    int aux=dist_c;
    int a=1, b=1;
    //cout<<"aa "<<dist_c<<' '<<dist_f<<'\n';
    for(int i=0; i<sz(c)-dist_c; i++){
        z.pb(add_and({c[i],c[aux]}));
        aux++;
    }
    aux=dist_f;
    //cout<<"ss"<<'\n';
    for(int i=0; i<sz(f)-dist_f; i++){
        q.pb(add_and({f[i],f[aux]}));
        aux++;
    }
    if(!(sz(z) && sz(q)))return;
     a=add_or(z);
     b=add_or(q);
    ans.pb(add_and({a,b}));
    q.clear();
    z.clear();
    //cout<<"ns"<<'\n';
}
void coso(){
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(i+j==k){
                q.pb(i*m+j);
            }
        }
    }
    add_or(q);
    return;
}
void construct_network(int H, int W, int K){
    n=H;
    m=W;
    k=K;
    if(min(n,m)==1){
        color();
        return;
    }
    if(max(n, m)>30){
        coso();
        return;
    }
    for(int i=0; i<n; i++){//por filas
        for(int j=0; j<m; j++){
            q.pb(i*m+j);
        }
        f.pb(add_or(q));
        q.clear();
    }
    for(int j=0; j<m; j++){//por columnas
        for(int i=0; i<n; i++){
            z.pb(i*m+j);
        }
        c.pb(add_or(z));
        z.clear();
    }
    //diferentes columnas y filas
    for(int dis=1; dis<k; dis++){
        looks(dis, k-dis);
        z.clear();
        q.clear();
    }
    //cout<<"avocado???????????????????????????????????"<<'\n';
    int a=add_or({add_xor(c),add_xor(f)});//debe ser 1 else 0
    //cout<<a<<" waaaaaaaaaaa"<<'\n';
    z.clear();
    q.clear();
    //igual columna
    int aux=k;
    for(int i=0; i<sz(c)-k; i++){
        z.pb(add_and({c[i],c[aux]}));
        aux++;
    }
    int b=0;
    if(sz(z)){
        b=add_and({a,add_or(z)});
        ans.pb(b);
    }
    //cout<<sz(ans)<<"<<<<<<<<"<< '\n';
    // igual fila
    aux=k;
    for(int i=0; i<sz(f)-k; i++){
        q.pb(add_and({f[i],f[aux]}));
        aux++;
    }
    if(sz(q)){
        //cout<<"nsssss"<<'\n';
        b=add_and({a,add_or(q)});
        ans.pb(b);
    }
    add_or(ans);
    return;
}
#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...