[PYTHON] JOI2019 / 2020 1st qualifying 3rd How to solve problems A and B

Thank you for your hard work in the 3rd qualifying session of JOI 2019/2020. Only B problem was solved during the contest. There is a commentary, so it should be open to the public. Languages used: C ++, Python3

A problem

qiita_joia.png # solution X < L At the time, L is output.

L <= X <= R At the time of, X is output.

R < X At the time, R is output.

code

A.cpp


#include <iostream>

using namespace std;

int main(){
    int X;
    int L;
    int R;
    cin >> X >> L >> R;
    if(X < L){
        cout << L << endl;
    }
    else if(L <= X and X <= R){
        cout << X << endl;
    }
    else if(R < X){
        cout << R << endl;
    }
}

that's all.

B problem

qiita_joi.png

solution

Replace the string "joi" with "JOI" using the Python3 replace function.

code

B.py


N, S = int(input())
print(S.replace('joi', 'JOI'))

that's all.

Impressions

It's a C problem, but I'm disappointed that I couldn't solve the A problem during the contest.

Recommended Posts

JOI2019 / 2020 1st qualifying 3rd How to solve problems A and B
How to solve slide puzzles and 15 puzzles
How to split and save a DataFrame
How to manage a README for both github and PyPI
13th Offline Real-time How to Solve Writing Problems in Python
How to write a metaclass that supports both python2 and python3
How to call a function
How to hack a terminal
How to set a shortcut to switch full-width and half-width with IBus
Overview of how to create a server socket and how to establish a client socket
SIGNATE [1st _Beginner Limited Competition] How to Solve Bank Customer Targeting
How to compare lists and retrieve common elements in a list
How to solve dynamic programming algorithm problems (as seen by beginners)
The 17th Offline Real-time How to Solve Writing Problems in Python
How to make a surveillance camera (Security Camera) with Opencv and Python
How to write offline real time Solve E04 problems in Python
[C language] How to create, avoid, and make a zombie process
Getting started on how to solve linear programming problems with PuLP
How to format a table using Pandas apply, pivot and swaplevel
How to write offline real time Solve F01 problems with Python
Python a + = b and a = a + b are different
How to make a Japanese-English translation
How to write a Python class
How to put a symbolic link
How to install and use Tesseract-OCR
How to solve simultaneous linear equations
How to create a Conda package
How to make a crawler --Advanced
How to make a recursive function
How to create a virtual bridge
How to install and configure blackbird
How to use .bash_profile and .bashrc
How to install CUDA and nvidia-driver
How to install and use Graphviz
How to make a deadman's switch
How to create a Dockerfile (basic)
[Blender] How to make a Blender plugin
How to delete a Docker container
[Python] return A [or / and] B
How to make a crawler --Basic
How to create a config file
How to divide and process a data frame using the groupby function
How to get a specific column name and index name in pandas DataFrame
How to put a half-width space before letters and numbers in Python.
How to make a container name a subdomain and make it accessible in Docker
How to stop a program in python until a specific date and time