답안 #293189

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
293189 2020-09-07T17:58:54 Z AlanChen Vision Program (IOI19_vision) C++14
0 / 100
17 ms 2128 KB
#include "vision.h"


#include <bits/stdc++.h>
using namespace std;

template<class A> using v=vector<A>;
template<class A,class B=A> using p=pair<A,B>;

typedef v<int> vi;
typedef p<int> pi;
typedef string str;

#define f first
#define s second
#define mp make_pair
#define ins insert
#define pb push_back
#define sz(S) (int)S.size()


#define get4(a,b,c,d,...) d

#define lp3(x,a,b) for(int x=(a);x<(b);x++)
#define lp2(x,a) lp3(x,0,a)
#define lp1(a) lp2(loopvar,a)
#define lp(x...) get4(x,lp3,lp2,lp1,0)(x)

#define trv(x,S) for(auto& x:(S))


int c0,c1;
struct num
{
	int x[8];
	num()
	{
		lp(i,8) x[i]=c0;
	}
};
num addnum(num n1,num n2)
{
	num ans;
	int carry=add_and({{n1.x[0],n2.x[0]}});
	ans.x[0]=add_xor({n1.x[0],n2.x[0]});
	lp(i,1,8){
		ans.x[i]=add_xor({carry,n1.x[i],n2.x[i]});
		if(i<7) carry=add_or({
			add_and({n1.x[i],n2.x[i]}),
					add_and({carry,n2.x[i]}),
					add_and({n1.x[i],carry})
		});
	}
	return ans;
}
num cplm(num n1)
{
	num ans;
	lp(i,8) ans.x[i]=add_not(n1.x[i]);

	num n2;
	n2.x[0]=c1;

	return addnum(ans,n2);
}

int n,m,tgt;
int orig[500][500];
int prj[2][500];
int disthelp[2][500][500];
int dist[2][500];
int isx[2][500];
int dim[2];




void construct_network(int H, int W, int Tgt)
{
	n=H,m=W,tgt=Tgt;


	{
		vi Ns;
		lp(i,n*m) {
			Ns.pb(i);
		}
		c1=add_or(Ns);
		c0=add_not(c1);
	}

	lp(i,n) lp(j,m) orig[i][j]=i*m+j;

	lp(i,n)
	{
		vi Ns;
		lp(j,m) Ns.pb(orig[i][j]);
		prj[0][i]=add_or(Ns);
	}
	lp(j,m)
	{
		vi Ns;
		lp(i,n) Ns.pb(orig[i][j]);
		prj[1][j]=add_or(Ns);
	}
	dim[0]=n,dim[1]=m;


	num fds[2];
	lp(d,2)
	{
		int issamebit[7];
		int consenbit[7];
		lp(i,7)
		{
			vi Ns; Ns.pb(c0);
			lp(j,dim[d]) if(bitset<8>(j)[i]) Ns.pb(prj[d][j]);
			issamebit[i]=add_not(add_xor(Ns));
			consenbit[i]=add_or(Ns);
		}
		num possnums[8][2];
		lp(numsame,8)
		{
			lp(i,numsame) lp(j,2) possnums[numsame][j].x[i]=consenbit[i];
			lp(i,numsame,7) lp(j,2){
				vi Ns; Ns.pb(c0);
				lp(alln,dim[d]) if(bitset<8>(alln)[numsame]==j&&bitset<8>(alln)[i]) Ns.pb(prj[d][alln]);
				possnums[numsame][j].x[i]=add_or(Ns);
			}
		}
		num curr[2];
		lp(j,2) curr[j]=possnums[0][j];

		lp(i,1,7) issamebit[i]=add_and({issamebit[i-1],issamebit[i]});

		lp(j,2) lp(ns,1,8) lp(bt,7){
			curr[j].x[bt]=add_or({
				add_and({issamebit[ns-1],possnums[ns][j].x[bt]}),
						add_and({add_not(issamebit[ns-1]),curr[j].x[bt]})
			});
		}
		num diff=addnum(curr[0],cplm(curr[1]));
		num diff2=cplm(diff);
		num fd;
		lp(bt,8) fd.x[bt]=add_or({
			add_and({diff2.x[7],diff.x[bt]}),
					add_and({diff.x[7],diff2.x[bt]})
		});
		fds[d]=fd;

	}
	num ttl=addnum(fds[0],fds[1]);

	vi ansarr;

	lp(i,8)
	{
		if(bitset<8>(tgt)[i]) ansarr.pb(ttl.x[i]);
		else ansarr.pb(add_not(ttl.x[i]));
	}

	add_and(ansarr);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 544 KB on inputs (0, 1), (0, 128), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 3 ms 788 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 4 ms 768 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 4 ms 768 KB Output is correct
11 Incorrect 4 ms 768 KB on inputs (0, 0), (0, 133), expected 1, but computed 0
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 2128 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -