Submission #253565

#TimeUsernameProblemLanguageResultExecution timeMemory
253565MrRobot_28ACM (COCI19_acm)C++17
50 / 50
7 ms1152 KiB
#include<bits/stdc++.h> using namespace std; bool cmp(pair <pair <string, int>, int> a, pair <pair <string, int>, int> b) { if(a.first.second != b.first.second) { return a.first.second > b.first.second; } if(a.second != b.second) { return a.second < b.second; } return a.first.first + b.first.first < b.first.first + a.first.first; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; vector <pair <pair <string, int>, int> > mass; vector <vector <string> > A(n, vector <string> (m + 1)); for(int i = 0; i < n; i++) { for(int j = 0; j < m + 1; j++) { cin >> A[i][j]; } } string s; cin >> s; int timer = 0; int kol = 0; for(int j = 0; j < m; j++) { string s1; cin >> s1; if(s1[0] == '+') { int cnt1 = 0, a = 0, b = 0, c = 0; int flag = 0; for(int j = 1; j < s1.size(); j++) { if(s1[j] == '/') { flag++; } else if(s1[j] == ':') { flag++; } else if(flag == 0) { cnt1 = cnt1 * 10 + (s1[j] - '0'); } else if(flag == 1) { a = a * 10 + (s1[j] - '0'); } else if(flag == 2) { b = b * 10 + (s1[j] - '0'); } else { c = c * 10 + (s1[j] - '0'); } } kol++; timer += a * 3600 + b * 60 + c + 1200 * cnt1; } } mass.push_back({{s, kol}, timer}); for(int i = 0; i < n; i++) { if(A[i][0] == s) { continue; } int kol1 = 0; int timer1 = 0; for(int j = 1; j <= m; j++) { if(A[i][j][0] == '-') { continue; } int cnt1 = 0, a = 0, b = 0, c = 0; int flag = 0; for(int k = 1; k < A[i][j].size(); k++) { if(A[i][j][k] == '/') { flag++; } else if(A[i][j][k] == ':') { flag++; } else if(flag == 0) { cnt1 = cnt1 * 10 + (A[i][j][k] - '0'); } else if(flag == 1) { a = a * 10 + (A[i][j][k] - '0'); } else if(flag == 2) { b = b * 10 + (A[i][j][k] - '0'); } else { c = c * 10 + (A[i][j][k] - '0'); } } timer1 += a * 3600 + b * 60 + c + 1200 * cnt1; kol1++; } mass.push_back({{A[i][0], kol1}, timer1}); } sort(mass.begin(), mass.end(), cmp); for(int i = 0; i < mass.size(); i++) { if(mass[i].first.first == s) { cout << i + 1; // return 0; } } return 0; }

Compilation message (stderr)

acm.cpp: In function 'int main()':
acm.cpp:43:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 1; j < s1.size(); j++)
                   ~~^~~~~~~~~~~
acm.cpp:91:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k = 1; k < A[i][j].size(); k++)
                   ~~^~~~~~~~~~~~~~~~
acm.cpp:124:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < mass.size(); i++)
                 ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...