Competencia OII
Los siguientes estudiantes seleccionados para competir en la Olimpiada Iberoamericana de Informática (OII) 2025 a celebrarse el domingo 22 de junio en el Colegio de Mayaguez:
Nombre | ID |
---|---|
Masa de Man | PR-01 |
Alvaro Daniel Villafuerte Gonzalez | PR-02 |
Gabriel Porch Santana | PR-03 |
He Eric Shan | PR-04 |
Sebastian Emil Rangel Mora | PR-05 |
Gael Rosario Contreras | PR-06 |
Austin Johnson Colón | PR-07 |
Manuel Alejandro Rodríguez Rosario | PR-08 |
Lucas Sebastian Carlo Franceschi | PR-09 |
Franco Pérez Méndez | PR-10 |
Juan S. Jiménez Rodríguez | PR-11 |
William Arjuna Deshmukh Porch | PR-12 |
Samuel Ralph Vélez | PR-13 |
Luis Carlos Collazo Carrión | PR-14 |
Juan Ignacio González Ramos | PR-15 |
son invitados para conversar sobre tópicos a tener en cuenta en la solución de problemas similares a la competencia.
Detalles del Evento:
- Fecha: Domingo, 15 de mayo
- Lugar: en línea en Google Meet: meet.google.com/dpp-mror-efe
- Duración: Más de dos horas, comenzando a las 9:00 a.m.
Soluciones prueba de selección 2025
- #include <stdio.h>
- //#define long long ll
- typedef long long ll;
- ll myDiff(ll a, ll b){
- ll d = a - b;
- if (d >= 0)
- return d;
- else
- return -1*d;
- }
- int main(){
- ll a, b;
- while (scanf("%lld %lld",&a ,&b) == 2)
- printf("%lld\n", myDiff(a, b));
- }
- #include <iostream>
- using namespace std;
- int main(){
- int n;
- cin>>n;
- string s;
- cin>>s;
- string as="ABC",bs="BABC",gs="CCAABB";
- int caa=0,cab=0,cag=0;
- for (int i=0;i<n;i++){
- if (s[i]==as[i%3])
- caa++;
- if (s[i]==bs[i%4])
- cab++;
- if (s[i]==gs[i%6])
- cag++;}
- int theMax=caa;
- if (theMax<cab)
- theMax=cab;
- if (theMax<cag)
- theMax=cag;
- cout<<theMax<<endl;
- if(caa==theMax)
- cout<<"Adrian"<<endl;
- if(cab==theMax)
- cout<<"Bruno"<<endl;
- if(cag==theMax)
- cout<<"Goran"<<endl;
- }
- #include <iostream>
- using namespace std;
- const string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_.,?";
- const string morseCode[] = {
- ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", // A-I
- ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", // J-R
- "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", // S-Z
- "..--", "---.", ".-.-", "----" // _ . , ?
- };
- string encode(string message, string &morseConcat, string &lengths) {
- for (char ch : message) {
- for (int i = 0; i < alphabet.size(); ++i) {
- if (ch == alphabet[i]) {
- string code = morseCode[i];
- morseConcat += code;
- lengths += to_string(code.size());
- break;
- }
- }
- }
- return morseConcat;
- }
- string decode(string morseConcat, string lengths) {
- string result = "";
- int pos = 0;
- for (int i = lengths.size() - 1; i >= 0; --i) {
- int len = lengths[i] - '0';
- string chunk = morseConcat.substr(pos, len);
- for (int j = 0; j < 30; ++j) {
- if (chunk == morseCode[j]) {
- result += alphabet[j];
- break;
- }
- }
- pos += len;
- }
- return result;
- }
- int main(){
- string line;
- while (getline(cin, line)){
- string morseConcat = "", lengths = "";
- encode(line, morseConcat, lengths);
- cout << decode(morseConcat, lengths) << endl;
- }
- }
- #include <iostream>
- using namespace std;
- int main(){
- int C;
- cin >> C;
- for (int i = 0; i < C; i++){
- string s, t;
- cin >> s >> t;
- int cnt_0_to_1 = 0, cnt_1_to_0 = 0;
- int cnt_q_to_1 = 0, cnt_q_to_0 = 0;
- int cnt1_s = 0, cnt1_t = 0;
- int total = 0;
- for (int i = 0; i < s.size(); ++i){
- if (s[i] == '1') cnt1_s++;
- if (t[i] == '1') cnt1_t++;
- if (s[i] == '0' && t[i] == '1') cnt_0_to_1++;
- else if (s[i] == '1' && t[i] == '0') cnt_1_to_0++;
- else if (s[i] == '?' && t[i] == '0') cnt_q_to_0++;
- else if (s[i] == '?' && t[i] == '1') cnt_q_to_1++;
- }
- if (cnt1_s > cnt1_t)
- total = -1;
- else{
- int swaps = min(cnt_0_to_1, cnt_1_to_0);
- int extra_flips = cnt_0_to_1 + cnt_1_to_0 - 2*swaps;
- total = swaps + extra_flips + cnt_q_to_0 + cnt_q_to_1;
- }
- cout << "Case " << i+1 << ": " << total << "\n";
- }
- }
Como se trabaja con números grandes se debe usar algunas de las siguientes opciones:
-
- Boost.Multiprecision:
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
cpp_int a; - GMP (GNU Multiple Precision Library):
#include <gmpxx.h>
mpz_class a; - Implementar tu propia clase de
BigInteger
y sobrecargar los operadores.
- Boost.Multiprecision:

TODO