Submission #293212

#TimeUsernameProblemLanguageResultExecution timeMemory
293212muhammad_hokimiyonVision Program (IOI19_vision)C++14
100 / 100
145 ms9712 KiB
#include "vision.h" #include <bits/stdc++.h> #define fi first #define se second using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n,m; int qur; vector < int > g; map < int , int > ll1,rr1; map < int , pair < int , int > > ll , rr; map < int , vector < int > > l,r; int o_r( vector < int > v ) { qur += 1; add_or( v ); return qur; } int an_d( vector < int > v ) { qur += 1; add_and( v ); return qur; } int xo_r( vector < int > v ) { qur += 1; add_xor( v ); return qur; } int no_t( int x ) { qur += 1; add_not( x ); return qur; } int foo( int k ) { vector < int > g,ff; for( int i = -(n + m); i <= n + m; i++ ){ if( l[i].empty() )continue; bool f = true; vector < int > ask; for( int j = i; j <= i + k; j++ ){ if( l[j].empty() ){ continue; } assert( ll.find(j) != ll.end() ); ask.push_back( ll[j].fi ); } if( (int)ask.size() < 1 )continue; //assert( (int)ask.size() == k + 1 ); int x = o_r( ask ); int y = xo_r( ask ); int z = no_t( y ); g.push_back( an_d( {x , z} ) ); g.push_back( ll1[i] ); } for( int i = -(n + m); i <= n + m; i++ ){ if( r[i].empty() )continue; bool f = true; vector < int > ask; for( int j = i; j <= i + k; j++ ){ if( r[j].empty() ){ continue; } assert( rr.find(j) != rr.end() ); ask.push_back( rr[j].fi ); } if( (int)ask.size() < 1 )continue; //assert( (int)ask.size() == k + 1 ); int x = o_r( ask ); int y = xo_r( ask ); int z = no_t( y ); ff.push_back( an_d( {x , z} ) ); ff.push_back( rr1[i] ); } return an_d( { o_r( g ), o_r( ff ) } ); } void construct_network(int H, int W, int K) { n = H; m = W; qur = n * m - 1; for( int i = 0; i < n; i++ ){ for( int j = 0; j < m; j++ ){ int x = i - j , y = i + j; l[x].push_back(i * m + j); r[y].push_back(i * m + j); } } for( int i = -(n + m); i <= n + m; i++ ){ if( l[i].empty() )continue; int x = o_r(l[i]); int y = xo_r(l[i]); ll[i] = { x , no_t(y) }; ll1[i] = an_d({ ll[i].fi , ll[i].se }); } for( int i = -(n + m); i <= n + m; i++ ){ if( r[i].empty() )continue; int x = o_r( r[i] ); int y = xo_r(r[i]); rr[i] = { x , no_t(y) }; rr1[i] = an_d( {rr[i].fi , rr[i].se} ); } int x = foo( K ); int y = foo( K - 1 ); y = no_t( y ); vector < int > f; f.push_back(x); f.push_back(y); an_d(f); // o_r( f ); }

Compilation message (stderr)

vision.cpp: In function 'int foo(int)':
vision.cpp:51:14: warning: unused variable 'f' [-Wunused-variable]
   51 |         bool f = true;
      |              ^
vision.cpp:70:14: warning: unused variable 'f' [-Wunused-variable]
   70 |         bool f = true;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...