Submission #497360

#TimeUsernameProblemLanguageResultExecution timeMemory
497360PedroBigManBit Shift Registers (IOI21_registers)C++17
33 / 100
7 ms1100 KiB
/* 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,S; vector<bool> lastbit; vector<bool> all; vector<bool> firstbit; ll ava1,ava2,ava3; void Order(ll a, ll b) //will replace register a with the minimum, register b with the maximum { 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 if(S==1) {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; S = (ll) s; 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,N) { if(i==M-4) {continue;} append_left(i,i,B-(i+1)*K); append_right(i,i,B-K); } //now line i has number i ava1=M-1; ava2=M-2; ava3=M-3; if(S==0) { REP(i,1,N) { if(i==M-4) { ava1=1; ava2=2; ava3=3; REP(j,M-3,min(N,M)) {append_move(j,M-4);} REP(j,M-4,min(N,M)) {append_left(j,j,B-(j+1)*K); append_right(j,j,B-K);} } Order(0,i); } } else { REP(i,0,N-1) { REP(j,i+1,N) {Order(i,j);} } } }

Compilation message (stderr)

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 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...