/*
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> allexceptfirstbit;
/*void Order(ll a, ll b) //will replace register a with the minimum, register b with the maximum
{
ll ava1=b+1,ava2=b+2;
append_store(ava2,lastbit);
append_not(ava1,b); 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_store(ava2,allexceptfirstbit); 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(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(allexceptfirstbit,B,true); allexceptfirstbit[0]=false;
REP(i,0,N-1) {append_move(i+1,0);} //now first N lines have line 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)
{
ll ava1=i+1,ava2=i+2; ll a=0; ll b=i;
append_store(ava2,lastbit);
append_not(ava1,b); 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_store(ava2,allexceptfirstbit); 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(b,b,ava1); //a has smallest, b has largest
}
}
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 |
Incorrect min value |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Incorrect min value |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Incorrect min value |
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 |
332 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |