제출 #317403

#제출 시각아이디문제언어결과실행 시간메모리
317403Jarif_RahmanVision Program (IOI19_vision)C++17
55 / 100
12 ms1152 KiB
#include "vision.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int h, w, k;
int cell(int i, int j){
    return i*w+j;
}
void p33(){
    vector <int> v;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) for(int a = 0; a <= k; a++){
        int x = i+a, y = j+k-a;
        if(x < h && y < w) v.pb(add_and({cell(i, j), cell(x, y)}));
        x = i-a, y = j+k-a;
        if(x >= 0 && y < w) v.pb(add_and({cell(i, j), cell(x, y)}));
    }
    add_or(v);
}
void p8(){
    vector <int> v;
    for(int i = 0; i <= k; i++){
        int j = k-i;
        if(i >= h || j >= w) continue;
        v.pb(add_and({0, cell(i, j)}));
    }
    add_or(v);
}
void construct_network(int H, int W, int K){
    h = H, w = W, k = K;
    if((h <= 10 && w <= 10) || min(h, w) == 1){
        p33();
        return;
    }
    if(k > 1){
        p8();
        return;
    }
    vector<int> hh, ww;
    for(int i = 0; i < h; i++){
        vector<int> temp;
        for(int j = 0; j < w; j++) temp.pb({cell(i, j)});
        hh.pb(add_or(temp));
    }
    for(int j = 0; j < w; j++){
        vector<int> temp;
        for(int i = 0; i < h; i++) temp.pb({cell(i, j)});
        ww.pb(add_or(temp));
    }
    vector<int> hw = hh; hw.insert(hw.end(), ww.begin(), ww.end());
    int in1 = add_xor(hw);
    vector<int> v;
    for(int i = 1; i < hh.size(); i++) v.pb(add_and({hh[i], hh[i-1]}));
    for(int i = 1; i < ww.size(); i++) v.pb(add_and({ww[i], ww[i-1]}));
    int in2 = add_or(v);
    add_and({in1, in2});
}

컴파일 시 표준 에러 (stderr) 메시지

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:56:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int i = 1; i < hh.size(); i++) v.pb(add_and({hh[i], hh[i-1]}));
      |                    ~~^~~~~~~~~~~
vision.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i = 1; i < ww.size(); i++) v.pb(add_and({ww[i], ww[i-1]}));
      |                    ~~^~~~~~~~~~~
#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...