This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size = 100000 | |
def f1(): | |
lista = list(range(size)) | |
eliminados = [] | |
for i in lista: | |
if i%2 != 0: | |
eliminados.append(lista.pop(lista.index(i))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
using namespace std; | |
struct Node { | |
long my_pos; | |
int valores[19] = {0}; | |
long filhos[20]; | |
bool folha() { return filhos[0] == -1; } | |
Node() { | |
for(int i = 0; i < 20; ++i) filhos[i] = -1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Array.IArray | |
type G = Array Int [Int] | |
g1 :: G | |
g1 = array (1, 4) [[], [1], [1], [2, 3]] | |
preds :: Int -> G -> [Int] | |
preds x g = g !! x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
struct UF { | |
vector<int> rank; | |
vector<int> root; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//======================================================================= | |
#include <boost/graph/adjacency_list.hpp> | |
#include <boost/graph/kruskal_min_spanning_tree.hpp> | |
#include <iostream> | |
#include <fstream> | |
int | |
main() | |
{ | |
using namespace boost; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p1 = "<S> ::= a<A> | a<C> | b<B> | b<C>\n<A> ::= a<F> | a<G>\n<B> ::= b<F> | b<G>\n<C> ::= a<A> | a<C> | b<B> | b<C>\n<F> ::= a<F> | b<F> | a<G> | b<G>\n<G> ::= &\n" | |
p2 = p1.split('\n') | |
p3 = map(lambda x : x.split('::='), p2) | |
p4 = list(map(lambda x : list(map(lambda y: y.split('|'), x)), p3)) | |
print(p4) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- INPUT: | |
4 300 | |
30 10 | |
20 50 | |
1 2 | |
4 6 | |
-} | |
{- OUTPUT: | |
900 | |
-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad.Trans.State.Strict | |
import Control.Monad | |
import Data.Ord | |
import Data.Maybe | |
import qualified Data.IntMap.Strict as M | |
data S = S { parentM :: M.IntMap Int | |
, rankM :: M.IntMap Int } | |
modifyP f = modify $ \s -> s { parentM = f (parentM s) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int expbin(int a, int e, int m, int acc) { | |
if (e == 0) return acc; | |
if (e % 2 == 1) return expbin(a, e-1, m, (acc * a) % m); | |
return expbin((a * a) % m, e/2, m, acc); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int n; | |
scanf("%d", &n); | |
int xs[n]; | |
int p_tam = 0; |