Submission #778697

# Submission time Handle Problem Language Result Execution time Memory
778697 2023-07-10T15:05:24 Z jasmin Vision Program (IOI19_vision) C++17
0 / 100
10 ms 1128 KB
#include "vision.h"
#include<bits/stdc++.h>
using namespace std;

int ind(int x, int y, int H, int W){
    assert(0<=x && x<H && 0<=y && y<W);
    return x*W + y;
}
bool valid(int x, int y, int H, int W){
    return (0<=x && x<H && 0<=y && y<W);
}

void construct_network_small(int H, int W, int K) {
	
    vector<int> ns_ans;
    int cnt=0;
    for(int x=0; x<H; x++){
        for(int y=0; y<W; y++){

            vector<int> ns;
            for(int i=0; i<=K; i++){

                int x2=x+i;
                int y2=y-(K-i);
                if(valid(x2, y2, H, W)){

                    ns.push_back(ind(x2, y2, H, W));
                }

                y2=y+(K-i);
                if(valid(x2, y2, H, W)){

                    ns.push_back(ind(x2, y2, H, W));
                }

            }

            if(!ns.empty()){

                add_or(ns); cnt++;
                add_and({ind(x, y, H, W), H*W + cnt-1}); cnt++;
                ns_ans.push_back(H*W + cnt-1);
            }
        }
    }

    add_or({ns_ans});
}

void construct_network_zero(int H, int W, int K){

    int x=0; int y=0;

    vector<int> ns;
    for(int i=0; i<=K; i++){

        int x2=x+i;
        int y2=y-(K-i);
        if(valid(x2, y2, H, W)){

            ns.push_back(ind(x2, y2, H, W));
        }

        y2=y+(K-i);
        if(valid(x2, y2, H, W)){

            ns.push_back(ind(x2, y2, H, W));
        }

    }

    int i=add_or(ns);
    add_and({0, i});
}

void construct_network1(int H, int W, int K){

    vector<int> orh(H);
    for(int i=0; i<H; i++){

        vector<int> ns;
        for(int j=0; j<W; j++){
            ns.push_back(i*W + j);
        }

        orh[i] = add_or(ns);
    }
    int samelineh = add_xor(orh);

    vector<int> orw(W);
    for(int j=0; j<W; j++){

        vector<int> ns;
        for(int i=0; i<H; i++){
            ns.push_back(i*W + j);
        }

        orw[j] = add_or(ns);
    }
    int samelinew = add_xor(orw);

    vector<int> andh(H);
    for(int i=0; i+1<H; i++){

        andh[i] = add_and({orh[i], orh[i+1]});
    }
    int neighboursh = add_or(andh);

    vector<int> andw(W);
    for(int i=0; i+1<W; i++){

        andw[i] = add_and({orw[i], orw[i+1]});
    }
    int neighboursw = add_or(andw);

    int ans = add_or({add_and({samelineh, neighboursw}), add_and({samelinew, neighboursh})});
}

void construct_network(int H, int W, int K){
    if(K==1){
        construct_network1(H, W, K);
        return;
    }
    if(H*W<=1000){
        construct_network_small(H, W, K);
        return;
    }
    construct_network_zero(H, W, K);
}

Compilation message

vision.cpp: In function 'void construct_network1(int, int, int)':
vision.cpp:116:9: warning: unused variable 'ans' [-Wunused-variable]
  116 |     int ans = add_or({add_and({samelineh, neighboursw}), add_and({samelinew, neighboursh})});
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 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 Incorrect 1 ms 212 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 Incorrect 1 ms 212 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 Incorrect 1 ms 212 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 Incorrect 1 ms 212 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 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 340 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1128 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Incorrect 1 ms 212 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -