답안 #599281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
599281 2022-07-19T12:21:10 Z FatihSolak Vision Program (IOI19_vision) C++17
0 / 100
9 ms 1104 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
int h,w,k;
int get_pos(int x,int y){
    return x*w + y;
}
void construct_network(int H, int W, int K) {
    h = H;
    w = W;
    k = K;
    map<int,int> row,col;
    int cnt = h*w;
    add_not(0);
    cnt++;
    add_or({0,cnt-1});
    int pos_1 = cnt++;
    for(int i = 0;i<h;i++){
        vector<int> v;
        for(int j = 0;j<w;j++){
            v.push_back(get_pos(i,j));
        }
        add_or(v);
        row[i] = cnt++;
    }
    for(int i = 0;i<w;i++){
        vector<int> v;
        for(int j = 0;j<h;j++){
            v.push_back(get_pos(j,i));
        }
        add_or(v);
        col[i] = cnt++;
    }
    map<int,int> row_dif,col_dif;
    for(int i = h-1;i>0;i--){
        if(k-i < 0 || k - i >= w)continue;
        vector<int> candidates;
        set<int> s;
        for(int j = 0;j<h;j++){
            if(j + i < h){
                s.insert(j);
            }
        }
        while(s.size()){
            vector<int> ask1;
            int num = *s.begin();
            ask1.push_back(row[num]);
            ask1.push_back(row[num + i]);
            s.erase(num);
            add_and(ask1);
            candidates.push_back(cnt++);
        }
        add_or(candidates);
        int now = cnt++;
        if(i != h-1){
            candidates.clear();
            for(int j = i + 1;j<h;j++){
                candidates.push_back(row_dif[j]);
            }
            add_or(candidates);
            int highers = cnt++;
            add_not(highers);
            int not_highers = cnt++;
            candidates = {now,not_highers};
            add_and(candidates);
            row_dif[i] = cnt++;
        }
        else{
            row_dif[i] = now;
        }
    }
    vector<int> tmp;
    tmp.push_back(pos_1);
    for(int i = 0;i<h;i++){
        tmp.push_back(row[i]);
    }
    add_xor(tmp);
    row_dif[0] = cnt++;
    
    
    for(int i = w-1;i>0;i--){
        if(k-i < 0 || k - i >= h)continue;
        vector<int> candidates;
        set<int> s;
        for(int j = 0;j<w;j++){
            if(j + i < w){
                s.insert(j);
            }
        }
        while(s.size()){
            vector<int> ask1;
            int num = *s.begin();
            ask1.push_back(col[num]);
            ask1.push_back(col[num + i]);
            s.erase(num);
            add_and(ask1);
            candidates.push_back(cnt++);
        }
        add_or(candidates);
        int now = cnt++;
        if(i != w-1){
            candidates.clear();
            for(int j = i + 1;j<w;j++){
                candidates.push_back(col_dif[j]);
            }
            add_or(candidates);
            int highers = cnt++;
            add_not(highers);
            int not_highers = cnt++;
            candidates = {now,not_highers};
            add_and(candidates);
            col_dif[i] = cnt++;
        }
        else{
            col_dif[i] = now;
        }
    }
    tmp.clear();
    tmp.push_back(pos_1);
    for(int i = 0;i<h;i++){
        tmp.push_back(col[i]);
    }
    add_xor(tmp);
    col_dif[0] = cnt++;
    vector<int> candidates;
    for(int i = 0;i<=min(h-1,k);i++){
        if(0 <= k-i && k-i < w){
            add_and({row_dif[i],col_dif[k-i]});
            candidates.push_back(cnt++);
        }
    }
    add_or(candidates);
    int answer = cnt++;
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:133:9: warning: unused variable 'answer' [-Wunused-variable]
  133 |     int answer = cnt++;
      |         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1104 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -