답안 #289624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289624 2020-09-02T19:38:36 Z Dremix10 Vision Program (IOI19_vision) C++17
14 / 100
12 ms 1152 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 1e18;
const int MOD = 1e9+7;

int N,M;

bool valid(int i, int j){
    return (i>=0 && i<N && j>=0 && j<M);
}

void solve_sub6(int n, int m, int k){
    vector<int> asks;
    map<pi,bool> v;

    int i = 0,j = 0;
    int di;
        vector<int> idx;
        int curr = i*m+j;
        //idx.push_back(curr);
        for(di=-k;di<=k;di++){
            int dj = k - abs(di);
            if(valid(i+di,j+dj)){
                int nxt = (i+di)*m+j+dj;
                if(!v[{min(nxt,curr),max(nxt,curr)}]){
                    idx.push_back(nxt);
                    v[{min(nxt,curr),max(nxt,curr)}]=true;
                }
            }
            //if(dj && valid(i+di,j-dj))
            //    idx.push_back((i+di)*m+j-dj);
        }
        p2(i,j)
        pv(idx)
        if(!idx.empty()){
            asks.push_back(add_xor(idx));
            asks.push_back(add_xor({curr}));
        }

    pv(asks)
    vector<int> fin;
    for(i=0;i<asks.size();i+=2)
        fin.push_back(add_and({asks[i],asks[i+1]}));
    pv(fin)
    int temp = add_or(fin);
    return;

}

void solve_sub7(int n, int m, int k){
    vector<int> rows,cols;
    int i,j;
    for(i=0;i<n;i++){
        vector<int> ask;
        for(j=0;j<m;j++)
            ask.push_back(i*m+j);
        pv(ask)
        rows.push_back(add_or(ask));
    }
    pv(rows)
    for(j=0;j<m;j++){
        vector<int> ask;
        for(i=0;i<n;i++)
            ask.push_back(i*m+j);
        pv(ask)
        cols.push_back(add_or(ask));
    }
    pv(cols)

    vector<int> rowsP,colsP;
    for(i=0;i+1<rows.size();i++)
        rowsP.push_back(add_and({rows[i],rows[i+1]}));
    for(i=0;i+1<cols.size();i++)
        colsP.push_back(add_and({cols[i],cols[i+1]}));
    vector<int> orz;
    int p1;
    if(rowsP.empty()){
        p1 = add_or(colsP);
    }
    else if(colsP.empty()){
        p1 = add_or(rowsP);
    }
    else{
        orz.push_back(add_or(rowsP));
        orz.push_back(add_or(colsP));
        p1 = add_xor(orz);
    }
    int p2 = add_xor({add_xor(rows),add_xor(cols)});
    int temp = add_and({p1,p2});
    return;
}

void construct_network(int n, int m, int k) {
    N = n;
    M = m;
	//solve_sub6(n,m,k);
	solve_sub7(n,m,k);
	return;
	//int arr[n][m];
    int i,j,di;
    //int temp = add_not(0);
    vector<int> asks;
    map<pi,bool> v;
    for(i=0;i<n;i++)
    for(j=0;j<m;j++){
        vector<int> idx;
        int curr = i*m+j;
        //idx.push_back(curr);
        for(di=-k;di<=k;di++){
            int dj = k - abs(di);
            if(valid(i+di,j+dj)){
                int nxt = (i+di)*m+j+dj;
                if(!v[{min(nxt,curr),max(nxt,curr)}]){
                    idx.push_back(nxt);
                    v[{min(nxt,curr),max(nxt,curr)}]=true;
                }
            }
            //if(dj && valid(i+di,j-dj))
            //    idx.push_back((i+di)*m+j-dj);
        }
        p2(i,j)
        pv(idx)
        if(!idx.empty()){
            asks.push_back(add_xor(idx));
            asks.push_back(add_xor({curr}));
        }
    }
    pv(asks)
    vector<int> fin;
    for(i=0;i<asks.size();i+=2)
        fin.push_back(add_and({asks[i],asks[i+1]}));
    pv(fin)
    int temp = add_or(fin);
    return;
}

/// g++ grader.cpp vision.cpp -Ddremix

Compilation message

vision.cpp: In function 'void solve_sub6(int, int, int)':
vision.cpp:68:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |     for(i=0;i<asks.size();i+=2)
      |             ~^~~~~~~~~~~~
vision.cpp:71:9: warning: unused variable 'temp' [-Wunused-variable]
   71 |     int temp = add_or(fin);
      |         ^~~~
vision.cpp: In function 'void solve_sub7(int, int, int)':
vision.cpp:97:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |     for(i=0;i+1<rows.size();i++)
      |             ~~~^~~~~~~~~~~~
vision.cpp:99:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |     for(i=0;i+1<cols.size();i++)
      |             ~~~^~~~~~~~~~~~
vision.cpp:115:9: warning: unused variable 'temp' [-Wunused-variable]
  115 |     int temp = add_and({p1,p2});
      |         ^~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:156:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  156 |     for(i=0;i<asks.size();i+=2)
      |             ~^~~~~~~~~~~~
vision.cpp:159:9: warning: unused variable 'temp' [-Wunused-variable]
  159 |     int temp = add_or(fin);
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1124 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 6 ms 768 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 10 ms 1152 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -