Skip to content

Instantly share code, notes, and snippets.

View rogerioagjr's full-sized avatar

Rogério Júnior rogerioagjr

View GitHub Profile
@rogerioagjr
rogerioagjr / conveyor_chaos.py
Created December 17, 2024 20:08
Meta Coding Puzzles - Level 4 - Conveyor Chaos (Python)
from typing import List
from sortedcontainers import SortedList
# Write any import statements here
def getMinExpectedHorizontalTravelDistance(N: int, H: List[int], A: List[int], B: List[int]) -> float:
conveyors = get_conveyors(H, A, B)
find_conveyors_below(conveyors)
find_init_probs(conveyors)
find_total_probs(conveyors)
@rogerioagjr
rogerioagjr / conveyor_chaos.cpp
Created December 17, 2024 20:06
Meta Coding Puzzles - Level 4 - Conveyor Chaos (C++)
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;
// Write any include statements here
struct Conveyor {
int height, left, right;
double init_prob, prob;
@rogerioagjr
rogerioagjr / mathematical_art.cpp
Created December 17, 2024 20:01
Meta Coding Puzzles - Level 4 - Mathematical Art (C++)
#include <bits/stdc++.h>
using namespace std;
// Write any include statements here
#define MAXN 4000200
long long bit[2 * MAXN];
void bit_upd(int idx, long long v) {
while (idx < 2 * MAXN) {
@rogerioagjr
rogerioagjr / mathematical_art.py
Last active December 17, 2024 20:01
Meta Coding Puzzles - Level 4 - Mathematical Art (Python)
from typing import List
from heapq import heappush, heappop
# Write any import statements here
def getPlusSignCount(N: int, L: List[int], D: str) -> int:
# Write your code here
horizontal_lines, vertical_lines = get_lines(L, D)
merged_hor_lines = get_merged_lines(horizontal_lines)
@rogerioagjr
rogerioagjr / toca.cpp
Created June 10, 2017 19:57
Toca do Saci
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1010
#define F first
#define S second
typedef pair<int,int> ii;
@rogerioagjr
rogerioagjr / cofre.cpp
Last active April 17, 2018 18:59
Segredo do Cofre
// Segredo do Cofre - F1P1 - OBI 2017
// Rogério Júnior
// O(N+M)
#include <cstdio> // scanf e printf
#include <algorithm> // min e max
using namespace std;
#define MAXN 100100 // defino o valor de MAXN
// Teleférico - F1P1 - OBI 2017
// Rogério Júnior
// Complexidade: O(1)
#include <cstdio> // scanf e printf
int main(){
// declaro e leio os valores de C e A
int c, a;
@rogerioagjr
rogerioagjr / drone.cpp
Last active May 25, 2017 15:25
Drone de Entrega
// Drone de Entrega - F1PJ - OBI 2017
// Rogério Júnior
// Complexidade: O(1)
#include <cstdio> // scanf e printf
int main(){
// declaro e leio os valores de A, B, C, H e L
int a, b, c, h, l;
// Bondinho - F1PJ - OBI 2017
// Rogério Júnior
// Complexidade: O(1)
#include <cstdio> // scanf e printf
int main(){
// declaro e leio os valores de A e M
int a, m;
@rogerioagjr
rogerioagjr / basic_treap.cpp
Last active March 28, 2017 13:16
Basic Treap
// Rogerio Junior - @rogerioagjr
// Basic Treap
#include <bits/stdc++.h>
using namespace std;
struct node{
int v, w;