Submission #711611

# Submission time Handle Problem Language Result Execution time Memory
711611 2023-03-17T09:46:19 Z guagua0407 ACM (COCI19_acm) C++17
50 / 50
3 ms 852 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end() 
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

int main() {_
    int n,m;
    cin>>n>>m;
    string res[n][m];
    string name[n];
    int node=0;
    for(int i=0;i<n;i++){
        cin>>name[i];
        if(name[i]=="NijeZivotJedanACM"){
            node=i;
        }
        for(int j=0;j<m;j++){
            cin>>res[i][j];
        }
    }
    cin>>name[node];
    for(int j=0;j<m;j++){
        cin>>res[node][j];
    }
    vector<pair<pair<ll,ll>,string>> vec;
    for(int i=0;i<n;i++){
        if(i==node) continue;
        ll cnt=0;
        ll tm=0;
        for(int j=0;j<m;j++){
            if(res[i][j][0]=='-') continue;
            cnt++;
            tm+=(res[i][j][1]-'0'-1)*20*60;
            int a=res[i][j][3]-'0';
            a=a*10+res[i][j][4]-'0';
            tm+=a*60*60;
            a=res[i][j][6]-'0';
            a=a*10+res[i][j][7]-'0';
            tm+=a*60;
            a=res[i][j][9]-'0';
            a=a*10+res[i][j][10]-'0';
            tm+=a;
        }
        vec.push_back({{-cnt,tm},name[i]});
    }
    ll cnt=0;
    ll tm=0;
    int i=node;
    for(int j=0;j<m;j++){
        if(res[i][j][0]=='-') continue;
        cnt++;
        tm+=(res[i][j][1]-'0'-1)*20*60;
        int a=res[i][j][3]-'0';
        a=a*10+res[i][j][4]-'0';
        tm+=a*60*60;
        a=res[i][j][6]-'0';
        a=a*10+res[i][j][7]-'0';
        tm+=a*60;
        a=res[i][j][9]-'0';
        a=a*10+res[i][j][10]-'0';
        tm+=a;
    }
    sort(all(vec));
    /*for(auto v:vec){
        cout<<v.f.f<<' '<<v.f.s<<' '<<v.s<<'\n';
    }*/
    pair<pair<ll,ll>,string> tmp={{-cnt,tm},name[node]};
    //cout<<tmp.f.f<<' '<<tmp.f.s<<' '<<tmp.s<<'\n';
    auto it=lower_bound(all(vec),tmp);
    cout<<it-vec.begin()+1;
    return 0;
}
//maybe its multiset not set

Compilation message

acm.cpp: In function 'void setIO(std::string)':
acm.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acm.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 2 ms 852 KB Output is correct