Skip to content

Commit 0c642f7

Browse files
committed
Problema: 3225
1 parent a99335a commit 0c642f7

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

categorias/adhoc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Ad-Hoc (256 / 892)
1+
# Ad-Hoc (257 / 892)
22

33

44

@@ -222,6 +222,7 @@
222222
- [x] [3175](https://www.beecrowd.com.br/repository/UOJ_3175.html) - [Os Presentes Do Noel](https://github.com/potigol/beecrowd/blob/master/src/3100/3175.poti)
223223
- [x] [3188](https://www.beecrowd.com.br/repository/UOJ_3188.html) - [Phone List](https://github.com/potigol/beecrowd/blob/master/src/3100/3188.poti)
224224
- [x] [3205](https://www.beecrowd.com.br/repository/UOJ_3205.html) - [Nasty Hacks](https://github.com/potigol/beecrowd/blob/master/src/3200/3205.poti)
225+
- [x] [3225](https://www.beecrowd.com.br/repository/UOJ_3225.html) - [Ordenação dos Pães](https://github.com/potigol/beecrowd/blob/master/src/3200/3225.poti)
225226
- [x] [3227](https://www.beecrowd.com.br/repository/UOJ_3227.html) - [Doorman](https://github.com/potigol/beecrowd/blob/master/src/3200/3227.poti)
226227
- [x] [3263](https://www.beecrowd.com.br/repository/UOJ_3263.html) - [Apague Com Segurança](https://github.com/potigol/beecrowd/blob/master/src/3200/3263.poti)
227228
- [x] [3278](https://www.beecrowd.com.br/repository/UOJ_3278.html) - [Passageiros de Trem](https://github.com/potigol/beecrowd/blob/master/src/3200/3278.poti)
@@ -763,7 +764,6 @@
763764
- [ ] [3212](https://www.beecrowd.com.br/repository/UOJ_3212.html) - Decomposição do Colar
764765
- [ ] [3219](https://www.beecrowd.com.br/repository/UOJ_3219.html) - Gokigen Naname
765766
- [ ] [3222](https://www.beecrowd.com.br/repository/UOJ_3222.html) - Cifra Playfair
766-
- [ ] [3225](https://www.beecrowd.com.br/repository/UOJ_3225.html) - Ordenação dos Pães
767767
- [ ] [3226](https://www.beecrowd.com.br/repository/UOJ_3226.html) - Seleção de Biscoito
768768
- [ ] [3228](https://www.beecrowd.com.br/repository/UOJ_3228.html) - Eco-driving
769769
- [ ] [3240](https://www.beecrowd.com.br/repository/UOJ_3240.html) - Doodling

src/3200/3225.poti

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
n = leia_inteiro
2+
a, c = leia_inteiros(" ").mutavel
3+
var b := Lista(n, 0).mutável
4+
5+
para i de 1 até n faça
6+
b[a[i]] := c[i]
7+
fim
8+
9+
var visto := Lista(n, falso).mutável
10+
var trocas := n
11+
para i de 1 até n se não visto[i] faça
12+
trocas := trocas - 1
13+
var j := i
14+
enquanto não visto[j] faça
15+
visto[j] := verdadeiro
16+
j := b[j]
17+
fim
18+
fim
19+
20+
escreva (se trocas mod 2 == 0 então "Possible" senão "Impossible" fim)

src/3200/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Problemas 3200 (24%)
1+
# Problemas 3200 (26%)
22

33
- [ ] [3200](https://www.beecrowd.com.br/repository/UOJ_3200.html) - Card Trick *Ad-Hoc*
44
- [ ] [3201](https://www.beecrowd.com.br/repository/UOJ_3201.html) - Traveling Salesman *Estruturas e Bibliotecas*
@@ -25,7 +25,7 @@
2525
- [ ] [3222](https://www.beecrowd.com.br/repository/UOJ_3222.html) - Cifra Playfair *Ad-Hoc*
2626
- [ ] [3223](https://www.beecrowd.com.br/repository/UOJ_3223.html) - Permutações de Código *Matemática*
2727
- [x] [3224](https://www.beecrowd.com.br/repository/UOJ_3224.html) - [Aaah!](https://github.com/potigol/beecrowd/blob/master/src/3200/3224.poti) *Iniciante*
28-
- [ ] [3225](https://www.beecrowd.com.br/repository/UOJ_3225.html) - Ordenação dos Pães *Ad-Hoc*
28+
- [x] [3225](https://www.beecrowd.com.br/repository/UOJ_3225.html) - [Ordenação dos Pães](https://github.com/potigol/beecrowd/blob/master/src/3200/3225.poti) *Ad-Hoc*
2929
- [ ] [3226](https://www.beecrowd.com.br/repository/UOJ_3226.html) - Seleção de Biscoito *Ad-Hoc*
3030
- [x] [3227](https://www.beecrowd.com.br/repository/UOJ_3227.html) - [Doorman](https://github.com/potigol/beecrowd/blob/master/src/3200/3227.poti) *Ad-Hoc*
3131
- [ ] [3228](https://www.beecrowd.com.br/repository/UOJ_3228.html) - Eco-driving *Ad-Hoc*

src/3400/3444.poti

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ var p, h := BigInt(a[2]) - 1 , BigInt(a[3]) - 1
66

77
w = para k de n até 1 passo -1 gere
88
c = pot2(k - 1, h) <= -1
9-
se c então h := pot2(k, h) fim
9+
se c então h := pot2(k, h) fim
1010
c
1111
fim
1212

1313
V, F = verdadeiro, falso
14-
ans = para k de n até 1 passo -1 gere
14+
saida = para k de n até 1 passo -1 gere
1515
pk1 = pot2(k - 1, p)
16-
escolha (w[k], pk1 >= 0)
17-
caso (V, V) => p := pk1 'L'
18-
caso (F, F) => p := -(pk1 + 1) 'L'
19-
caso (V, F) => p := pot2(k, p) 'R'
20-
caso (F, V) => 'R'
16+
p := escolha (w[k], pk1 >= 0)
17+
caso (V, V) => pk1 # L
18+
caso (F, F) => -(pk1 + 1) # L
19+
caso (V, F) => pot2(k, p) # R
20+
caso (F, V) => p # R
2121
fim
22-
fim
23-
escreva ans.junte("")
22+
se w[k] == (pk1 >= 0) então 'L' senão 'R' fim
23+
fim.junte("")
24+
25+
escreva saida

0 commit comments

Comments
 (0)