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.
Banner Google Meet

Soluciones prueba de selección 2025

  1. #include <stdio.h>
  2. //#define long long ll
  3. typedef long long ll;
  4. ll myDiff(ll a, ll b){
  5. ll d = a - b;
  6. if (d >= 0)
  7. return d;
  8. else
  9. return -1*d;
  10. }
  11. int main(){
  12. ll a, b;
  13. while (scanf("%lld %lld",&a ,&b) == 2)
  14. printf("%lld\n", myDiff(a, b));
  15. }
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int n;
  5. cin>>n;
  6. string s;
  7. cin>>s;
  8. string as="ABC",bs="BABC",gs="CCAABB";
  9. int caa=0,cab=0,cag=0;
  10. for (int i=0;i<n;i++){
  11. if (s[i]==as[i%3])
  12. caa++;
  13. if (s[i]==bs[i%4])
  14. cab++;
  15. if (s[i]==gs[i%6])
  16. cag++;}
  17. int theMax=caa;
  18. if (theMax<cab)
  19. theMax=cab;
  20. if (theMax<cag)
  21. theMax=cag;
  22. cout<<theMax<<endl;
  23. if(caa==theMax)
  24. cout<<"Adrian"<<endl;
  25. if(cab==theMax)
  26. cout<<"Bruno"<<endl;
  27. if(cag==theMax)
  28. cout<<"Goran"<<endl;
  29. }
  1. #include <iostream>
  2. using namespace std;
  3. const string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_.,?";
  4. const string morseCode[] = {
  5. ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", // A-I
  6. ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", // J-R
  7. "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", // S-Z
  8. "..--", "---.", ".-.-", "----" // _ . , ?
  9. };
  10. string encode(string message, string &morseConcat, string &lengths) {
  11. for (char ch : message) {
  12. for (int i = 0; i < alphabet.size(); ++i) {
  13. if (ch == alphabet[i]) {
  14. string code = morseCode[i];
  15. morseConcat += code;
  16. lengths += to_string(code.size());
  17. break;
  18. }
  19. }
  20. }
  21. return morseConcat;
  22. }
  23. string decode(string morseConcat, string lengths) {
  24. string result = "";
  25. int pos = 0;
  26. for (int i = lengths.size() - 1; i >= 0; --i) {
  27. int len = lengths[i] - '0';
  28. string chunk = morseConcat.substr(pos, len);
  29. for (int j = 0; j < 30; ++j) {
  30. if (chunk == morseCode[j]) {
  31. result += alphabet[j];
  32. break;
  33. }
  34. }
  35. pos += len;
  36. }
  37. return result;
  38. }
  39. int main(){
  40. string line;
  41. while (getline(cin, line)){
  42. string morseConcat = "", lengths = "";
  43. encode(line, morseConcat, lengths);
  44. cout << decode(morseConcat, lengths) << endl;
  45. }
  46. }
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int C;
  5. cin >> C;
  6. for (int i = 0; i < C; i++){
  7. string s, t;
  8. cin >> s >> t;
  9. int cnt_0_to_1 = 0, cnt_1_to_0 = 0;
  10. int cnt_q_to_1 = 0, cnt_q_to_0 = 0;
  11. int cnt1_s = 0, cnt1_t = 0;
  12. int total = 0;
  13. for (int i = 0; i < s.size(); ++i){
  14. if (s[i] == '1') cnt1_s++;
  15. if (t[i] == '1') cnt1_t++;
  16. if (s[i] == '0' && t[i] == '1') cnt_0_to_1++;
  17. else if (s[i] == '1' && t[i] == '0') cnt_1_to_0++;
  18. else if (s[i] == '?' && t[i] == '0') cnt_q_to_0++;
  19. else if (s[i] == '?' && t[i] == '1') cnt_q_to_1++;
  20. }
  21. if (cnt1_s > cnt1_t)
  22. total = -1;
  23. else{
  24. int swaps = min(cnt_0_to_1, cnt_1_to_0);
  25. int extra_flips = cnt_0_to_1 + cnt_1_to_0 - 2*swaps;
  26. total = swaps + extra_flips + cnt_q_to_0 + cnt_q_to_1;
  27. }
  28. cout << "Case " << i+1 << ": " << total << "\n";
  29. }
  30. }

Como se trabaja con números grandes se debe usar algunas de las siguientes opciones:

    1. Boost.Multiprecision:
      #include <boost/multiprecision/cpp_int.hpp>
      using boost::multiprecision::cpp_int;
      cpp_int a;
    2. GMP (GNU Multiple Precision Library):
      #include <gmpxx.h>
      mpz_class a;
    3. Implementar tu propia clase de BigInteger y sobrecargar los operadores.
Indicaciones solución P5 selección OiPR 2025

TODO