ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1974. Similar Tunes

No subject
Posted by D4nick 18 Sep 2020 22:29
G++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
void zapisatnotu(string s, vector <int> & notyish, int i) {
    int okt = s[0] - '0';
    string nota(s, 1, 2);
    if (nota == "B+") {
        okt++;
    }
    if (nota == "C-") {
        okt--;
    }
    if (nota == "C" || nota == "B+") {
        notyish[i] = (okt - 1) * 12 + 1;
    }
    if (nota == "C+" || nota == "D-") {
        notyish[i] = (okt - 1) * 12 + 2;
    }
    if (nota == "D") {
        notyish[i] = (okt - 1) * 12 + 3;
    }
    if (nota == "D+" || nota == "E-") {
        notyish[i] = (okt - 1) * 12 + 4;
    }
    if (nota == "E" || nota == "F-") {
        notyish[i] = (okt - 1) * 12 + 5;

    }
    if (nota == "F" || nota == "E+") {
        notyish[i] = (okt - 1) * 12 + 6;

    }
    if (nota == "F+" || nota == "G-") {
        notyish[i] = (okt - 1) * 12 + 7;

    }
    if (nota == "G") {
        notyish[i] = (okt - 1) * 12 + 8;
    }
    if (nota == "G+" || nota == "A-") {
        notyish[i] = (okt - 1) * 12 + 9;

    }
    if (nota == "A") {
        notyish[i] = (okt - 1) * 12 + 10;

    }
    if (nota == "A+" || nota == "B-") {
        notyish[i] = (okt - 1) * 12 + 11;

    }
    if (nota == "B" || nota == "C-") {
        notyish[i] = (okt - 1) * 12 + 12;
    }
}
void sravnit(vector <int> & notyish, vector <int> & noty) {
    int MAX = 0;
    for (int inish = 0; inish < notyish.size(); inish++) {
        int per = 0;
        for (int in = 0; in < noty.size() && inish + in < notyish.size(); in++) {
            if (notyish[inish+in] == noty[in])
                per++;
        }
        if (per > MAX)
            MAX = per;
    }
    for (int in = 0; in < noty.size(); in++) {
        int per = 0;
        for (int inish = 0; inish < notyish.size() && inish + in < noty.size(); inish++) {
            if (noty[in+inish] == notyish[inish])
                per++;
        }
        if (per > MAX)
            MAX = per;
    }
    float ans = float(MAX) / float(noty.size());
    cout.precision(6);
    cout.setf(ios::fixed);
    cout << ans << '\n';
}
int main(){
cin.sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    string s;    vector <int> notyish(n);
    for (int i = 0; i < n; i++) {
        cin >> s;
        zapisatnotu(s, notyish, i);
    }
    int m; cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> n;
        vector <int> noty(n);
        for (int i = 0; i < n; i++) {
            cin >> s;
            zapisatnotu(s, noty, i);
        }
        sravnit(notyish, noty);
    }
}

Edited by author 18.09.2020 22:34