Submission #955318

# Submission time Handle Problem Language Result Execution time Memory
955318 2024-03-30T06:13:15 Z 8pete8 Vision Program (IOI19_vision) C++17
0 / 100
14 ms 2008 KB
#include "vision.h"
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
/*
int cnt=0;
vector<int>keep;
int add_or(vector<int>v){
	cnt++;
	int x=0;
	for(auto i:v)x|=keep[i];
	keep.pb(x);
	return keep.size()-1;
}
int add_and(vector<int>v){
	cnt++;
	int x=1;
	for(auto i:v)x&=keep[i];
	keep.pb(x);
	return keep.size()-1;
	return 0;
}
int add_xor(vector<int>v){
	cnt++;
	int x=0;
	for(auto i:v)x^=keep[i];
	keep.pb(x);
	return keep.size()-1;
	return 0;
}*/
void construct_network(int h, int w, int k){
	vector<int>ans;
	auto valid=[&](int a,int b){
		if(a<0||b<0||a>=h||b>=w)return false;
		return true;
	};
	auto get=[&](int a,int b){return a*w+b;};
	auto dist=[&](int a,int b,int x,int y){return abs(a-x)+abs(b-y);};
	vector<vector<bool>>done(h+1,vector<bool>(w+1,0));
	auto getdiag=[&](int a,int b,int x,int y,vector<int>&v,int mode){
		while(dist(a,b,x,y)==k){
			if(valid(a,b))v.pb(get(a,b));
			if(mode)a--,b--;
			else a++,b--;
		}
	};
	if(k==1){
		for(int i=0;i<h;i+=h-1){
			for(int j=0;j<w;j++){
				vector<int>v;
				getdiag(i,j+k,i,j,v,1);
				getdiag(i,j+k,i,j,v,0);
				getdiag(i+k,j,i,j,v,1);
				getdiag(i-k,j,i,j,v,0);
				if(!v.empty()){
					int x=add_or(v);
					ans.pb(add_and({get(i,j),x}));
				}
			}
			if(h==1)break;
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j+=w-1){
				vector<int>v;
				getdiag(i,j+k,i,j,v,1);
				getdiag(i,j+k,i,j,v,0);
				getdiag(i+k,j,i,j,v,1);
				getdiag(i-k,j,i,j,v,0);
				if(!v.empty()){
					int x=add_or(v);
					ans.pb(add_and({get(i,j),x}));
				}
			}
			if(w==1)break;
		}
		vector<int>idrow(h),idcol(w);
		vector<int>row2(h),col2(w);
		for(int i=0;i<h;i++){
			vector<int>v;
			for(int j=0;j<w;j++)v.pb(get(i,j));
			if(v.size())idrow[i]=add_or(v);
		}
		for(int j=0;j<w;j++){
			vector<int>v;
			for(int i=0;i<h;i++)v.pb(get(i,j));
			if(v.size())idcol[j]=add_or(v);
		}
		for(int i=2;i<w-1;i++)col2[i]=add_or({idcol[i],idcol[i-1]});
		for(int i=2;i<h-1;i++)row2[i]=add_or({idrow[i],idrow[i-1]});
		for(int k=0;k<2;k++){
			vector<int>v,v2;
			for(int i=2;i<col2.size()-1;i++)v.pb(col2[i]);
			for(auto i:idrow)v2.pb(i);
			if(v.size()&&v2.size()){
				int x=add_xor(v2);
				int y=add_xor(v);
				vector<int>bruh={x,y};
				ans.pb(add_and(bruh));
			}
			swap(col2,row2);
			swap(idrow,idcol);
		}
		if(ans.size())add_or(ans);
		return;
	}
	for(int i=0;i<h;i++)for(int j=0;j<w;j++){
		vector<int>v;
		if(h>30&&w>30){
			getdiag(i,j+k,i,j,v,1);
			getdiag(i,j+k,i,j,v,0);
			if(v.size()){
				int x=add_or(v);
				x=add_and({get(i,j),x});
			}
			return;
		}
		getdiag(i,j+k,i,j,v,1);
		getdiag(i,j+k,i,j,v,0);
		getdiag(i+k,j,i,j,v,1);
		getdiag(i-k,j,i,j,v,0);
		if(!v.empty()){
			int x=add_or(v);
			ans.pb(add_and({get(i,j),x}));
		}
	}
	sort(all(ans));
	ans.erase(unique(all(ans)),ans.end());
	add_or(ans);
	return;
}/*
int32_t main(){
	int a,b,k;cin>>a>>b>>k;
	int x,y,x2,y2;cin>>x>>y>>x2>>y2;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(i==x&&j==y)keep.pb(1);
		else if(i==x2&&j==y2)keep.pb(1);
		else keep.pb(0);
	}
	construct_network(a,b,k);
	cout<<keep.back()<<'\n';
	cout<<cnt<<'\n';
}*/

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:122:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  122 |    for(int i=2;i<col2.size()-1;i++)v.pb(col2[i]);
      |                ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 2 ms 984 KB WA in grader: Too many instructions
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 2 ms 984 KB WA in grader: Too many instructions
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 2 ms 984 KB WA in grader: Too many instructions
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 2 ms 984 KB WA in grader: Too many instructions
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB on inputs (0, 1), (0, 3), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 14 ms 2008 KB Output is correct
5 Correct 11 ms 1496 KB Output is correct
6 Correct 6 ms 860 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Incorrect 2 ms 1240 KB WA in grader: Too many instructions
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1372 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Incorrect 2 ms 604 KB on inputs (40, 15), (42, 15), expected 0, but computed 1
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 2 ms 984 KB WA in grader: Too many instructions
4 Halted 0 ms 0 KB -