Submission #799018

# Submission time Handle Problem Language Result Execution time Memory
799018 2023-07-31T08:44:29 Z lollipop Vision Program (IOI19_vision) C++17
22 / 100
13 ms 2132 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define ll long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod =  1000000007 ;
const int mod1 = 998244353 ;
const int NN = 6e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;

#include "vision.h"



// static const int MAX_INSTRUCTIONS = 10000;
// static const int MAX_INPUTS = 1000000;

// static const int _AND = 0;
// static const int _OR = 1;
// static const int _XOR = 2;
// static const int _NOT = 3;

// static inline bool increasing(int a, int b, int c) {
// 	return a <= b && b <= c;
// }

// [[noreturn]] static inline void error(string message) {
// 	printf("%s\n", message.c_str());
// 	exit(0);
// }

// class InstructionNetwork {

// 	struct Instruction {
// 		int type;
// 		vector<int> input_indexes;

// 		inline Instruction(int _type, const vector<int>& _input_indexes):
// 				type(_type), input_indexes(_input_indexes) {
// 		}

// 		inline int apply(int a, int b) const {
// 			switch (type) {
// 				case _AND:
// 					return a & b;
// 				case _OR:
// 					return a | b;
// 				case _XOR:
// 					return a ^ b;
// 				default:
// 					return 0;
// 			}
// 		}

// 		inline int compute(const vector<int>& memory_cells) const {
// 			int r = memory_cells[input_indexes[0]];
// 			if (type == _NOT)
// 				return 1 - r;
// 			for (int j = 1; j < (int)input_indexes.size(); j++)
// 				r = apply(r, memory_cells[input_indexes[j]]);
// 			return r;
// 		}
// 	};

// 	int input_size;
// 	int total_inputs;
// 	vector<Instruction> instructions;

// public:

// 	inline void init(int _input_size) {
// 		this->input_size = _input_size;
// 		this->total_inputs = 0;
// 		this->instructions.clear();
// 	}

// 	inline int add_instruction(int type, const vector<int>& input_indexes) {
// 		if (input_indexes.size() == 0)
// 			error("Instruction with no inputs");

// 		if (instructions.size() + 1 > MAX_INSTRUCTIONS)
// 			error("Too many instructions");

// 		if (total_inputs + input_indexes.size() > MAX_INPUTS)
// 			error("Too many inputs");

// 		instructions.emplace_back(type, input_indexes);
// 		total_inputs += input_indexes.size();
// 		int new_index = input_size + (int)instructions.size() - 1;

// 		for (int input_index : input_indexes)
// 			if (!increasing(0, input_index, new_index-1))
// 				error("Invalid index");

// 		return new_index;
// 	}

// 	inline int compute(vector<int> &memory_cells) const {
// 		for (auto &instruction : instructions)
// 			memory_cells.push_back(instruction.compute(memory_cells));
// 		return memory_cells.back();
// 	}
// };


// static InstructionNetwork instructionNetwork;
// int add_and(vector<int> Ns) {
// 	return instructionNetwork.add_instruction(_AND, Ns);
// }

// int add_or(vector<int> Ns) {
// 	return instructionNetwork.add_instruction(_OR, Ns);
// }

// int add_xor(vector<int> Ns) {
// 	return instructionNetwork.add_instruction(_XOR, Ns);
// }

// int add_not(int N) {
// 	vector<int> Ns = {N};
// 	return instructionNetwork.add_instruction(_NOT, Ns);
// }


void construct_network(int H, int W, int K){
     int a[ H ][ W ] ;
	 FOR( i , H ) FOR( j , W ){
		a[ i ][ j ] = i * W + j ; 
	 }
	 if( K == 1 ){
       vector < int > nec ;
	   int app_h[ H ] , app_w[ W ] ;
	   FOR( i , H ){
		 vector < int > vu ;
		 FOR( j , W ) vu.pb( a[ i ][ j ] ) ;
		 int x = add_or( vu ) ;
		 app_h[ i ] = x ;
	   }
	   FOR( j , W ){
		 vector < int > vu ;
		 FOR( i , H ) vu.pb( a[ i ][ j ] ) ;
		 int x = add_or( vu ) ;
		 app_w[ j ] = x ;
	   }	   
	   FOR( i , H - 1 ){
		 vector < int > vu ; 
		 vu.pb( app_h[ i ] ) ; vu.pb( app_h[ i + 1 ] ) ;
		 int z = add_and( vu ) ;
		 vu.clear() ; 
		 FOR( j , W ) vu.pb( app_w[ j ] ) ;
		 int k = add_xor( vu ) ;
		 vu.clear() ;
		 vu.pb( z ) ; vu.pb( k ) ;
		 int xx = add_and( vu ) ;
		 nec.pb( xx ) ;
	   }
	   FOR( j , W - 1 ){
		 vector < int > vu ; 
		 vu.pb( app_w[ j ] ) ; vu.pb( app_w[ j + 1 ] ) ;
		 int z = add_and( vu ) ;
		 vu.clear() ; 
		 FOR( i , H ) vu.pb( app_h[ i ] ) ;
		 int k = add_xor( vu ) ;
		 vu.clear() ;
		 vu.pb( z ) ; vu.pb( k ) ;
		 int xx = add_and( vu ) ;
		 nec.pb( xx ) ;
	   }	
	   int x = add_or( nec ) ;   
	   return ;
	 }
    if( max( H , W ) > 30 ){
      vector < int > nec ;
	  nec.pb( a[ 0 ][ 0 ] ) ;
	  vector < int > vu ;
      FOR( i , H ){
		FOR( j , W ){
           if( ( i + j ) == K ) vu.pb( a[ i ][ j ] ) ;
		}
	  }
     int z = add_or( vu ) ;
	 nec.pb( z ) ;
	 int x = add_and( nec ) ;
	 return ;
	}
    vector < int > nec ; 
	FOR( i , H ){
		FOR( j , W ){
          vector < int > vu ;
		  FOR( i1 , H ){
			FOR( j1 , W ){
				if( abs( i - i1 ) + abs( j - j1 ) != K ) continue ;
				vu.pb( a[ i1 ][ j1 ] ) ;
			}
		  }
          int zz = add_or( vu ) ; 
		  vu.clear() ;
		  vu.pb( zz ) ; vu.pb( a[ i ][ j ] ) ;
		  int kk = add_and( vu ) ;
		  nec.pb( kk ) ;
		}
	}
	int x = add_or( nec ) ;
	return ;

}

// int main() {
// 	int H, W, K;
// 	assert(3 == scanf("%d%d%d", &H, &W, &K));

// 	FILE *log_file = fopen("log.txt","w");

// 	instructionNetwork.init(H * W);
// 	construct_network(H, W, K);

// 	while (true) {
// 		int rowA, colA, rowB, colB;
// 		assert(1 == scanf("%d", &rowA));
// 		if (rowA == -1)
// 			break;
// 		assert(3 == scanf("%d%d%d", &colA, &rowB, &colB));

// 		if ((!increasing(0, rowA, H-1)) ||
// 			(!increasing(0, colA, W-1)) ||
// 			(!increasing(0, rowB, H-1)) ||
// 			(!increasing(0, colB, W-1)) ||
// 			(rowA == rowB && colA == colB)) {
// 			printf("-1\n");
// 			fprintf(log_file, "-1\n");
// 			fflush(stdout);
// 			fflush(log_file);
// 			continue;
// 		}

// 		vector<int> memory_cells;
// 		for (int row = 0; row < H; row++)
// 			for (int col = 0; col < W; col++) {
// 				bool active = (row == rowA && col == colA) || (row == rowB && col == colB);
// 				memory_cells.push_back(active ? 1 : 0);
// 			}
// 		int computation_result = instructionNetwork.compute(memory_cells);

// 		printf("%d\n", computation_result);
// 		fflush(stdout);

// 		for(int i = 0; i < (int)memory_cells.size(); i++)
// 			fprintf(log_file, (i ? " %d" : "%d"), memory_cells[i]);
// 		fprintf(log_file, "\n");
// 		fflush(log_file);
// 	}
// 	fclose(stdin);
// }

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:191:9: warning: unused variable 'x' [-Wunused-variable]
  191 |     int x = add_or( nec ) ;
      |         ^
vision.cpp:205:7: warning: unused variable 'x' [-Wunused-variable]
  205 |   int x = add_and( nec ) ;
      |       ^
vision.cpp:225:6: warning: unused variable 'x' [-Wunused-variable]
  225 |  int x = add_or( nec ) ;
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 212 KB on inputs (0, 1), (0, 100), expected 1, but computed 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 288 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 6 ms 1200 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 8 ms 1236 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 13 ms 2072 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2132 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 6 ms 1236 KB Output is correct
8 Correct 6 ms 1236 KB Output is correct
9 Correct 12 ms 2092 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -