Submission #636741

# Submission time Handle Problem Language Result Execution time Memory
636741 2022-08-30T01:22:30 Z iee Titlovi (COCI19_titlovi) C++17
50 / 50
1 ms 340 KB
// iee
#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using namespace std;
void work(int);

template <class T> void read(T &x) {
  x = 0;
  int f = 1, ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  x *= f;
}

int main() {
  int TT = 1; // cin >> TT;
  rep(CAS, 1, TT)
    work(CAS);
  return 0;
}
struct SRT {
  int id, tl, tr;
  vector<string> nr;
};
SRT Get() {
  int id;
  scanf("%d", &id);
  int tlh, tlm, tls, tlms, tl;
  int trh, trm, trs, trms, tr;
  scanf("%d:%d:%d,%d --> %d:%d:%d,%d\n", &tlh, &tlm, &tls, &tlms, &trh, &trm, &trs, &trms);
  tl = tlh * 1000 * 60 * 60 + tlm * 1000 * 60 + tls * 1000 + tlms;
  tr = trh * 1000 * 60 * 60 + trm * 1000 * 60 + trs * 1000 + trms;
  vector<string> nr;
  string s;
  do {
    getline(cin, s);
    nr.push_back(s);
  } while (s.size() != 0 && s != "#");
  return (SRT) {id, tl, tr, nr};
}
void print(SRT srt) {
  cout << srt.id << endl;
  int tl = srt.tl, tr = srt.tr;
  int tlh, tlm, tls, tlms;
  int trh, trm, trs, trms;
  tlms = tl % 1000, tl = (tl - tlms) / 1000;
  tls = tl % 60, tl = (tl - tls) / 60;
  tlm = tl % 60, tl = (tl - tlm) / 60;
  tlh = tl;
  
  trms = tr % 1000, tr = (tr - trms) / 1000;
  trs = tr % 60, tr = (tr - trs) / 60;
  trm = tr % 60, tr = (tr - trm) / 60;
  trh = tr;
  printf("%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n", tlh, tlm, tls, tlms, trh, trm, trs, trms);
  for (string it: srt.nr) cout << it << endl;
}
void work(int CASE) {
  vector<SRT> srt;
  while (1) {
    srt.push_back(Get());
    if (srt.back().nr.back() == "#") break;
  }
  int T;
  scanf("%d", &T);
  for (SRT &it: srt) {
    it.tl += T, it.tr += T;
  }
  for (SRT it: srt)
    print(it);
}

Compilation message

titlovi.cpp: In function 'SRT Get()':
titlovi.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%d", &id);
      |   ~~~~~^~~~~~~~~~~
titlovi.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |   scanf("%d:%d:%d,%d --> %d:%d:%d,%d\n", &tlh, &tlm, &tls, &tlms, &trh, &trm, &trs, &trms);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
titlovi.cpp: In function 'void work(int)':
titlovi.cpp:77:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |   scanf("%d", &T);
      |   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct