Submission #222355

# Submission time Handle Problem Language Result Execution time Memory
222355 2020-04-13T05:12:49 Z dwsc ACM (COCI19_acm) C++14
40 / 50
71 ms 896 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<string,vector<string>> vs;
typedef pair<int,int> ii;
string target ="NijeZivotJedanACM";
vs actual;
ii score(vs team){
    vector<string> use;
    ii val = ii(0,0);
    if (team.first == target){
        use = actual.second;
        for (int i = 0; i < use.size(); i++){
            string sub = use[i];
            if (sub[0] == '+'){
                val.first++;
                int slash = -1;
                string subtime = "";
                for (int j = 3; j < sub.length(); j++){
                    subtime += sub[j];
                }
                val.second -= (sub[1]-48)*1200;
                val.second -= (((subtime[1]-48)*3600)+((subtime[3]-48)*360)+((subtime[4]-48)*60)+((subtime[6]-48)*10)+(subtime[7]-48));
            }
        }
    }
    else{
        use = team.second;
        for (int i = 0; i < use.size(); i++){
            string sub = use[i];
            if (sub[0] == '+' || sub[0] == '?'){
                val.first++;
                int slash = -1;
                string subtime = "";
                for (int j = 3; j < sub.length(); j++){
                    subtime += sub[j];
                }
                val.second -= (sub[1]-48)*1200;
                val.second -= (((subtime[1]-48)*3600)+((subtime[3]-48)*360)+((subtime[4]-48)*60)+((subtime[6]-48)*10)+(subtime[7]-48));
            }
        }
    }
    return val;
}
bool cmp(vs team1,vs team2){
    ii s1 = score(team1),s2 = score(team2);
    if (s1 > s2) return 1;
    if (s2 > s1) return 0;
    return (team1.first < team2.first);
}
int main(){
    int n,m;
    cin >> n >> m;
    vs arr[n];
    for (int i = 0; i < n; i++){
        string name;
        cin >> name;
        vector<string> subs;
        for (int j = 0; j < m; j++){
            string sub;
            cin >> sub;
            subs.push_back(sub);
        }
        arr[i] = vs(name,subs);
    }
    string name;
    cin >> name;
    vector<string> subs;
    for (int i = 0; i < m; i++){
        string sub;
        cin >> sub;
        subs.push_back(sub);
    }
    actual = vs(name,subs);
    sort(arr,arr+n,cmp);
    for (int i = 0; i < n; i++) if (arr[i].first == target) cout << i+1;
}

Compilation message

acm.cpp: In function 'ii score(vs)':
acm.cpp:12:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < use.size(); i++){
                         ~~^~~~~~~~~~~~
acm.cpp:18:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int j = 3; j < sub.length(); j++){
                                 ~~^~~~~~~~~~~~~~
acm.cpp:16:21: warning: unused variable 'slash' [-Wunused-variable]
                 int slash = -1;
                     ^~~~~
acm.cpp:28:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < use.size(); i++){
                         ~~^~~~~~~~~~~~
acm.cpp:34:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int j = 3; j < sub.length(); j++){
                                 ~~^~~~~~~~~~~~~~
acm.cpp:32:21: warning: unused variable 'slash' [-Wunused-variable]
                 int slash = -1;
                     ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 71 ms 896 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 59 ms 896 KB Output is correct
5 Incorrect 58 ms 896 KB Output isn't correct