Submission #497326

# Submission time Handle Problem Language Result Execution time Memory
497326 2021-12-23T03:09:15 Z PedroBigMan Bit Shift Registers (IOI21_registers) C++17
0 / 100
1 ms 204 KB
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
#include "registers.h"
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 500000000LL
#define EPS 0.00000001
#define pi 3.14159
#define VV(vvvv,NNNN,xxxx); REP(i,0,NNNN) {vvvv.pb(xxxx);}
ll mod=1000000007LL;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 

ll N,M,K,B;
vector<bool> lastbit;
vector<bool> all;
vector<bool> firstbit;

void Order(ll a, ll b) //will replace register a with the minimum, register b with the maximum
{
	ll ava1=N+1,ava2=N+2,ava3=N+3;;
	append_store(ava2,lastbit); append_store(ava3,firstbit);
	append_not(ava1,b); append_add(ava1,ava1,ava3); append_add(ava1,a,ava1); append_and(ava1,ava1,ava2); //now, at ava1, we have 0...01 if a is smaller than b, 0...00 else
	append_right(ava1,ava1,B-1); append_xor(ava1,ava1,ava3); append_store(ava2,all); append_add(ava1,ava1,ava2); //now, at ava1, 1...1 if a is smaller, 0...0 else
	append_and(ava2,a,ava1); //ava2 has a if a is smaller, 0...0 else
	append_not(ava1,ava1); append_and(ava1,b,ava1); //ava1 has b if b is smaller or equal, 0...0 else
	append_add(b,a,b); append_add(a,ava1,ava2); //b has sum of a and b, a has smallest of a,b
	append_not(ava1,a); append_add(ava1,ava1,ava3); append_add(b,b,ava1); //a has smallest, b has largest
}

void construct_instructions(int s, int n, int k, int q) 
{
	N = (ll) n; K = (ll) k; M = 100; B = 2000;
	VV(lastbit,B,false); lastbit[1999]=true; VV(all,B,true); VV(firstbit,B,false); firstbit[0]=true;
	REP(i,0,N-1) {append_move(i+1,0);} //now first N lines have line 0
	REP(i,0,4000) {append_move(i+1,0);}
	REP(i,0,N)
	{
		append_left(i,i,B-(i+1)*K); append_right(i,i,B-K);
	}
	//now line i has number i
	REP(i,1,N)
	{
		Order(0,i);
	}
}

Compilation message

registers.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("O3")
      | 
registers.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("unroll-loops")
      |
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer detected in grader
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer detected in grader
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -