Submission #432032

# Submission time Handle Problem Language Result Execution time Memory
432032 2021-06-17T19:16:27 Z mosiashvililuka Vision Program (IOI19_vision) C++14
0 / 100
14 ms 11588 KB
#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
const int N=200;
int a,b,c,d,e,i,j,ii,jj,zx,xc,k,OR[1009][1009],TWO[1009][1009],K,COUNTI,MASIVI[1000009],nuli;
vector <pair <int, int> > X[1009],Y[1009];
vector <int> vv,v,va,vz,vx;
//
/*int add_xor(vector <int> q){
	if(q.size()==0){
		cout<<"ADDXOR";
		exit(0);
	}
	int qw=0;
	for(int qq=0; qq<q.size(); qq++){
		qw^=MASIVI[q[qq]];
	}
	COUNTI++;MASIVI[COUNTI]=qw;
	return COUNTI;
}
int add_or(vector <int> q){
	if(q.size()==0){
		cout<<"ADDOR";
		exit(0);
	}
	int qw=0;
	for(int qq=0; qq<q.size(); qq++){
		qw|=MASIVI[q[qq]];
	}
	COUNTI++;MASIVI[COUNTI]=qw;
	return COUNTI;
}
int add_and(vector <int> q){
	if(q.size()==0){
		cout<<"ADDAND";
		exit(0);
	}
	int qw=1;
	for(int qq=0; qq<q.size(); qq++){
		qw&=MASIVI[q[qq]];
	}
	COUNTI++;MASIVI[COUNTI]=qw;
	return COUNTI;
}
int add_not(int q){
	int qq=0;
	if(MASIVI[q]==0) qq=1; else qq=0;
	COUNTI++;MASIVI[COUNTI]=qq;
	return COUNTI;
}*/
//
int TWONUMBER(vector <int> q){
	int qw=0,we=0;
	vector <int> QW,WE;
	//QW.push_back(q);QW.push_back(w);
	qw=add_or(q);we=add_xor(q);
	WE.push_back(qw);WE.push_back(we);
	return add_xor(WE);
}
int F(int q, int w){
	return q*b+w;
}
int READ(int q, int w){
	if(w%K==K-1){
		return TWO[w][q];
	}
	if(q%K==0){
		return TWO[q-1][w];
	}
	int qw=w/K;qw*=K;qw--;
	int QW=0,WE=0,ER=0,RT=0;
	vz.clear();vz.push_back(TWO[qw][q]);vz.push_back(TWO[qw][w]);
	
	vx.clear();vx.push_back(OR[qw][q]);vx.push_back(OR[qw][w]);
	vz.push_back(TWONUMBER(vx));
	return add_or(vz);
}
int solve(int KK){
	K=KK;
	int QW=0,WE=0;
	
	//X
	
	
	for(i=K-1; i<1000; i+=K){
		vv.clear();
		for(j=i; j>i-K; j--){
			for(vector <pair <int, int> >::iterator it=X[j].begin(); it!=X[j].end(); it++){
				vv.push_back(F((*it).first,(*it).second));
			}
			if(vv.size()!=0) OR[i][j]=add_or(vv); else OR[i][j]=nuli;
			if(vv.size()!=0) e=add_xor(vv); else e=nuli;
			v.clear();v.push_back(OR[i][j]);v.push_back(e);
			TWO[i][j]=add_xor(v);
		}
		vv.clear();
		for(j=i+1; j<min(i+K,1001); j++){
			for(vector <pair <int, int> >::iterator it=X[j].begin(); it!=X[j].end(); it++){
				vv.push_back(F((*it).first,(*it).second));
			}
			if(vv.size()!=0) OR[i][j]=add_or(vv); else OR[i][j]=nuli;
			if(vv.size()!=0) e=add_xor(vv); else e=nuli;
			v.clear();v.push_back(OR[i][j]);v.push_back(e);
			TWO[i][j]=add_xor(v);
		}
	}
	//exit(0);
	//cout<<MASIVI[READ(0,2)]<<"    "<<K;
	//exit(0);
	va.clear();
	for(i=0; i<1000-K-1; i++){
		int ee=READ(i,i+K-1);
		//cout<<MASIVI[ee]<<endl;
		va.push_back(ee);
	}
	QW=add_or(va);
	//exit(0);
	
	
	//Y
	
	
	for(i=K-1; i<1000; i+=K){
		vv.clear();
		for(j=i; j>i-K; j--){
			for(vector <pair <int, int> >::iterator it=Y[j].begin(); it!=Y[j].end(); it++){
				vv.push_back(F((*it).first,(*it).second));
			}
			if(vv.size()!=0) OR[i][j]=add_or(vv); else OR[i][j]=nuli;
			if(vv.size()!=0) e=add_xor(vv); else e=nuli;
			v.clear();v.push_back(OR[i][j]);v.push_back(e);
			TWO[i][j]=add_xor(v);
		}
		vv.clear();
		//for(j=i+1; j<1000; j++){
		for(j=i+1; j<min(i+K,1001); j++){
			for(vector <pair <int, int> >::iterator it=Y[j].begin(); it!=Y[j].end(); it++){
				vv.push_back(F((*it).first,(*it).second));
			}
			if(vv.size()!=0) OR[i][j]=add_or(vv); else OR[i][j]=nuli;
			if(vv.size()!=0) e=add_xor(vv); else e=nuli;
			v.clear();v.push_back(OR[i][j]);v.push_back(e);
			TWO[i][j]=add_xor(v);
		}
	}
	//exit(0);
	va.clear();
	for(i=0; i<1000-K-1; i++){
		va.push_back(READ(i,i+K-1));
		//if(i>=5) exit(0);
	}
	WE=add_or(va);
	//exit(0);
	//cout<<MASIVI[QW]<<" "<<MASIVI[WE]<<"    "<<K<<endl;
	va.clear();va.push_back(QW);va.push_back(WE);
	return add_and(va);
}
void construct_network(int H, int W, int KK) {
	if(H*W==2){
		vv.clear();vv.push_back(0);vv.push_back(1);
		nuli=add_xor(vv);
	}else{
		vv.clear();vv.push_back(0);vv.push_back(1);vv.push_back(2);
		nuli=add_and(vv);
	}
	a=H;b=W;k=KK;
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			X[i+j+N].push_back(make_pair(i,j));
			Y[i-j+N].push_back(make_pair(i,j));
		}
	}
	int AX=solve(k);
	int AZ=solve(k+1);
	//cout<<MASIVI[AX]<<" "<<MASIVI[AZ]<<endl;
	vv.clear();vv.push_back(AZ);vv.push_back(AX);
	add_xor(vv);
}






/*int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b>>k;
	cin>>c>>d>>zx>>xc;
	MASIVI[F(c,d)]=1;
	MASIVI[F(zx,xc)]=1;
	COUNTI=F(a-1,b-1);
	c=0;d=0;zx=0;xc=0;
	construct_network(a,b,k);
	cout<<MASIVI[COUNTI];
	return 0;
}*/

Compilation message

vision.cpp: In function 'int READ(int, int)':
vision.cpp:71:6: warning: unused variable 'QW' [-Wunused-variable]
   71 |  int QW=0,WE=0,ER=0,RT=0;
      |      ^~
vision.cpp:71:11: warning: unused variable 'WE' [-Wunused-variable]
   71 |  int QW=0,WE=0,ER=0,RT=0;
      |           ^~
vision.cpp:71:16: warning: unused variable 'ER' [-Wunused-variable]
   71 |  int QW=0,WE=0,ER=0,RT=0;
      |                ^~
vision.cpp:71:21: warning: unused variable 'RT' [-Wunused-variable]
   71 |  int QW=0,WE=0,ER=0,RT=0;
      |                     ^~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 9032 KB Output is correct
2 Incorrect 5 ms 6212 KB WA in grader: Too many instructions
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 9032 KB Output is correct
2 Incorrect 5 ms 6212 KB WA in grader: Too many instructions
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 9032 KB Output is correct
2 Incorrect 5 ms 6212 KB WA in grader: Too many instructions
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 9032 KB Output is correct
2 Incorrect 5 ms 6212 KB WA in grader: Too many instructions
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 9032 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9024 KB Output is correct
2 Incorrect 5 ms 6212 KB WA in grader: Too many instructions
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 11588 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 9032 KB Output is correct
2 Incorrect 5 ms 6212 KB WA in grader: Too many instructions
3 Halted 0 ms 0 KB -