Submission #370398

# Submission time Handle Problem Language Result Execution time Memory
370398 2021-02-24T01:28:32 Z Mamnoon_Siam Bitaro, who Leaps through Time (JOI19_timeleap) C++17
0 / 100
2 ms 492 KB
#include <bits/stdc++.h>
using namespace std;

/* sorry, this is the bare minimum :'( */
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1005;

int n, q;
int L[N], R[N];

ll query(int i, int j, int t1, int t2) {
  int inc = j < i ? -1 : 1;
  ll ans = 0;
  while(i != j) {
    if(t1 > R[i]-1) {
      ans += t1 - (R[i] - 1);
      t1 = R[i]-1;
    } else if(t1 < L[i]) {
      t1 = L[i];
    }
    ++t1;
    debug(t1);
    i += inc;
  }
  ans += max(0, t1 - t2);
  return ans;
}

int main(int argc, char const *argv[])
{
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%d %d", &n, &q);
  for(int i = 1; i < n; ++i) {
    scanf("%d %d", &L[i], &R[i]);
  }
  while(q--) {
    int op; scanf("%d", &op);
    if(op == 1) {
      int p; scanf("%d", &p);
      scanf("%d %d", &L[p], &R[p]);
    } else {
      int i, j, t1, t2;
      scanf("%d %d %d %d", &i, &t1, &j, &t2);
      printf("%lld\n", query(i, j, t1, t2));
    }
  }
  return 0;
}

Compilation message

timeleap.cpp: In function 'll query(int, int, int, int)':
timeleap.cpp:56:20: warning: statement has no effect [-Wunused-value]
   56 | #define debug(...) 42
      |                    ^~
timeleap.cpp:75:5: note: in expansion of macro 'debug'
   75 |     debug(t1);
      |     ^~~~~
timeleap.cpp: In function 'int main(int, const char**)':
timeleap.cpp:87:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   87 |   scanf("%d %d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~~
timeleap.cpp:89:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   89 |     scanf("%d %d", &L[i], &R[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:92:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   92 |     int op; scanf("%d", &op);
      |             ~~~~~^~~~~~~~~~~
timeleap.cpp:94:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   94 |       int p; scanf("%d", &p);
      |              ~~~~~^~~~~~~~~~
timeleap.cpp:95:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   95 |       scanf("%d %d", &L[p], &R[p]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:98:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   98 |       scanf("%d %d %d %d", &i, &t1, &j, &t2);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 492 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -