Submission #1018076

# Submission time Handle Problem Language Result Execution time Memory
1018076 2024-07-09T13:53:40 Z cadmiumsky Radio Towers (IOI22_towers) C++17
41 / 100
4000 ms 1430460 KB
#include "towers.h"

#include <vector>
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;
using ld = long double;

#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

const int nmax = 2e5 + 5;
int v[nmax];

namespace DSU {
   int dsu[nmax], nxt[nmax];
   int mxR[nmax];

   void init(int l, int r) {
      for(int i = l; i <= r; i++) dsu[i] = i, nxt[i] = i + 1;
      return;
   }
   int f(int x) { return x == dsu[x]? x : dsu[x] = f(dsu[x]); }
   void unite(int x, int y) {
      x = f(x);
      y = f(y);
      if(x == y) return;
      if(x > y) swap(x, y);
      dsu[y] = x;
      mxR[x] = max(mxR[x], mxR[y]);
      nxt[x] = nxt[y];
      return;
   }
   int coef(int i, const vector<int>& p) {
      i = f(i);
      return mxR[i] - max(v[p[i]], v[p[nxt[i]]]);
   }
}

int timeout[nmax];
int dir[nmax];

void initglobals(signed L, signed R) {
   
   ++L;
   ++R;
   
   vector<int> p;
   for(int i = L; i <= R; i++) {
      if((i == L  || v[i] < v[i - 1]) && (i == R || v[i] < v[i + 1])) p.emplace_back(i), timeout[i] = 1e9 + 5;
      else timeout[i] = 0;
   }
   
   DSU::init(0, sz(p));
   
   set<pii> heap;
   
   set<int> indemnizatii;
   for(int i = 0; i < sz(p) - 1; i++) {
      indemnizatii.emplace(i);
      indemnizatii.emplace(i + 1);
      int mx = v[p[i] + 1];
      for(int j = p[i] + 2; j < p[i + 1]; j++)
         mx = max(mx, v[j]);
      DSU::mxR[i] = mx;
      heap.emplace(mx - max(v[p[i]], v[p[i + 1]]), i);
   }
   
   auto get = [&](int p_) { return pii{DSU::coef(p_, p), p_}; };
      
   while(!heap.empty()) {
      auto [C, i] = *heap.begin();
      heap.erase(heap.begin());
      
      i = DSU::f(i);
      int urm = DSU::nxt[i];
      if(i != *indemnizatii.begin()) {
         int ant = DSU::f(i - 1);
         heap.erase(heap.find(get(ant)));
      }
      if(urm != *indemnizatii.rbegin()) 
         heap.erase(heap.find(get(urm)));
      
      if(v[p[i]] < v[p[urm]]) {
         timeout[p[urm]] = C;
         dir[p[urm]] = p[i];
         DSU::unite(i, urm);
         indemnizatii.erase(urm);
         if(i != *indemnizatii.begin()) {
            int ant = DSU::f(i - 1);
            heap.insert(get(ant));
         }
         if(i != *indemnizatii.rbegin())
            heap.insert(get(i));
         
      }
      else {
         timeout[p[i]] = C;
         dir[p[i]] = p[urm];
         if(i != *indemnizatii.begin()) {
            int ant = DSU::f(i - 1);
            DSU::unite(ant, i);
            heap.insert(get(ant));
         }
         if(urm != *indemnizatii.rbegin())
            heap.insert(get(urm));
         indemnizatii.erase(i);
      }  
   }
}


template<typename T>
struct AINT {
   struct Node {
      Node *l, *r;
      T inner;
   };
   Node mem[nmax * 100];
   int cnt = 0;
   using ns = Node*;
   
   int n;
   ns root, nil;
   int filled = 0;
   void init(int n_) {
      n = n_;
      nil = newnode(0, 0, T());
      nil -> l = nil;
      nil -> r = nil;
      root = nil;
      root = walk([&](T& inner, int cl, int cr) {
         if(cl != cr) return 1;
         inner = T();
         return 0;
      });
   }
   
   ns newnode(ns L, ns R, T val) {
      mem[cnt++] = (Node{L, R, val});
      return mem + cnt - 1;
   }
   ns newnode() {
      return newnode(nil, nil, T());
   }
   
   template<class CB> ns walk(CB&& cb) { filled ++; return root = walk(cb, 1, n); }
   template<class CB> ns walk(CB&& cb, int l, int r) { return root = walk(cb, l, r, root, 1, n); }
   template<class CB> ns walk(CB&& cb, int l, int r, ns node, int cl, int cr) { 
      if(r < cl || cr < l) return node;
      auto a = node -> inner;
      if(l <= cl && cr <= r && !cb(node -> inner, cl, cr)) { auto rv = newnode(node -> l, node -> r, node -> inner); node -> inner = a;  return rv; }
      int mid = (cl + cr) >> 1;
      auto herenow = newnode();
      herenow -> l = walk(cb, l, r, node -> l, cl, mid);
      herenow -> r = walk(cb, l, r, node -> r, mid + 1, cr);
      //cerr << cl << ' ' << cr << "\t" << herenow -> inner.val << '\t' << herenow -> l -> inner.val << '\t' << herenow -> r -> inner.val << '\n';
      herenow -> inner.pull(herenow -> l -> inner, herenow -> r -> inner);
      return herenow;
   }
   
   
   template<class CB> void const_walk(CB&& cb, ns start) const { return const_walk(cb, start, 1, n); }
   template<class CB> void const_walk(CB&& cb, ns start, int l, int r) const { return const_walk(cb, l, r, start, 1, n); }
   template<class CB> void const_walk(CB&& cb, int l, int r, ns node, int cl, int cr) const { 
      if(r < cl || cr < l) return;
      if(l <= cl && cr <= r && !cb(node -> inner, cl, cr)) return;
      int mid = (cl + cr) >> 1;
      const_walk(cb, l, r, node -> l, cl, mid);
      const_walk(cb, l, r, node -> r, mid + 1, cr);
      return;
   }
};

struct Sum {
   int val;
   Sum(int a = 0): val(a) {;}
   void pull(const Sum& L, const Sum& R) { val = L.val + R.val; }
};

struct mnidx {
   int val;
   mnidx(int a = 0): val(a) {;}
   void pull(const mnidx& L, const mnidx& R) { val = v[L.val] < v[R.val]? L.val : R.val; }
};

struct mxval {
   int val;
   mxval(int a = 0): val(a) {;}
   void pull(const mxval& L, const mxval& R) { val = max(L.val, R.val); }
};

map<int, AINT<Sum>::ns> sumroot;
map<int, AINT<mnidx>::ns> raiseroot, fallroot;

AINT<Sum> sum_aint;
AINT<mnidx> dir_aint;
AINT<mxval> max_aint;

void init(signed N, std::vector<signed> H) {
   //cerr << N << ' ' << sz(H) << '\n';
   v[0] = 1e9 + 2;
   for(int i = 0; i < N; i++) v[i + 1] = H[i]; 
   initglobals(0, N - 1);
   max_aint.init(N);
   max_aint.walk([&](auto &a, int cl, int cr) { if(cl != cr) return 1; a.val = v[cl]; return 0; });
   

   vector<int> idx(N); iota(all(idx), 1);
   sum_aint.init(N);
   sort(all(idx), [&](int a, int b) { return timeout[a] > timeout[b]; });
   for(auto x : idx)
      sumroot[timeout[x]] = sum_aint.walk([&](auto& a, int cl, int cr) { a.val = 1; return 0;}, x, x);
      //cerr << timeout[x] << '\t' << sum_aint.root -> inner.val << '\n';
      
   dir_aint.init(N);
   sort(all(idx), [&](int a, int b) { return dir[a] < dir[b]; });
   raiseroot[0] = dir_aint.root;
   for(auto x : idx) 
      raiseroot[dir[x]] = dir_aint.walk([&](auto& a, int cl, int cr) { a.val = cl * (timeout[cl] != 0); return 0; }, x, x); 
   for(int i = 1; i <= N; i++) if(raiseroot.count(i) == 0) raiseroot[i] = raiseroot[i - 1];
   
   dir_aint.init(N);
   sort(all(idx), [&](int a, int b) { return dir[a] > dir[b]; });
   fallroot[N + 1] = dir_aint.root;
   for(auto x : idx) 
      fallroot[dir[x]] = dir_aint.walk([&](auto& a, int cl, int cr) { a.val = cl * (timeout[cl] != 0); return 0; }, x, x); 
   for(int i = N; i > 0; i--) if(fallroot.count(i) == 0) fallroot[i] = fallroot[i + 1];
   
   
   return;
}

int query_max(int l, int r) { 
   //cerr << l << ' ' << r << '\n';
   int mx = 0;
   max_aint.const_walk([&](auto& a, int cl, int cr) { mx = max(mx, a.val); return 0;}, max_aint.root, l, r);
   return mx;
}

int pula_pizda(signed L, signed R, signed D) {
   ++L, ++R;
   
   
   if([&]() {
      for(int i = L; i <= R; i++) 
         if(timeout[i] != 0) return 0;
      return 1;
   }()) {
      int mx = 0;
      for(int i = L; i <= R; i++) mx = max(mx, v[i]);
      return mx - max(v[L], v[R]) >= D? 2 : 1;
   }
   
   int l = L, r = R;
   while (l <= r && timeout[l] < D) l++;
   if(l > r) return 1;
   
   cerr << L << ' ' << l << '\t';
   
   int rez = 0;
   if(L < l) {
      
      int mn = L;
      for(int i = L + 1; i < l; i++) if(dir[i] < L && timeout[i] != 0 && v[mn] > v[i]) mn = i;
      cerr << mn << '\n';
      int mx = 0; 
      for(int i = mn + 1; i < l; i++) mx = max(v[i], mx);
      
      if(mx - max(v[l], v[mn]) >= D) rez++;
   }
   cerr << '\n';
   
   while(timeout[r] < D) r--;
   
   cerr <<r << ' ' << R << '\n';
   
   if(r < R) {
      int mn = R;
      for(int i = r + 1; i < R; i++) if(dir[i] > R && timeout[i] != 0 && v[mn] > v[i]) mn = i;
      cerr << mn << '\n';
      int mx = 0;
      for(int i = r + 1; i < mn; i++) mx = max(v[i], mx);
      if(mx - max(v[r], v[mn]) >= D) rez++;
   }
   
   for(int i = l; i <= r; i++)
      if(timeout[i] >= D) rez++;
   return rez;
}

signed max_towers(signed L, signed R, signed D) {
   //pula_pizda(L, R, D);
   //cerr << "vreodata\n";
   ++L, ++R;
   if(sumroot.lower_bound(D) == sumroot.end()) return 1;
   auto forsum = sumroot.lower_bound(D) -> second;
   
   
   int alltogether = 0;
   sum_aint.const_walk([&](auto a, int cl, int cr) { alltogether += a.val; return 0; }, forsum, L, R);
   //cerr << alltogether << '\n';
   if(alltogether == 0) {
      int mx = query_max(L, R);
      return mx - max(v[L], v[R]) >= D? 2 : 1;
   }
   
   int l = L, r = L;
   sum_aint.const_walk([&](auto &a, int cl, int cr) { 
      if(l < cl) return 0; 
      if(a.val == 0) { l = cr + 1; return 0; } 
      if(cl == cr) { l = cl; return 0; } 
      return 1; }, forsum, L, R);
   
   int rez = alltogether;
   
   //cerr << L << ' ' << l << '\t';
   
   if(L < l) {
      int mn = L;
      dir_aint.const_walk([&](mnidx& a, int cl, int cr) { if(v[mn] > v[a.val]) mn = a.val; return 0;}, raiseroot[L - 1], L + 1, l - 1);
      
      //cerr << mn;
      for(int i = L + 1; i < l; i++) if(dir[i] < L && timeout[i] != 0 && v[mn] > v[i]) mn = i;
      int mx = query_max(mn + 1, l);
      
      if(mx - max(v[l], v[mn]) >= D) rez++;
   }
   //cerr << '\n';
   
   int limit = alltogether - 1;
   
   sum_aint.const_walk([&](auto &a, int cl, int cr) { 
      if(r < cl) return 0; 
      if(a.val <= limit) { limit -= a.val; r = cr + 1; return 0; } 
      if(cl == cr) { r = cl; return 0; } 
      return 1; }, forsum, L, R);
   
   //cerr << r << ' ' << R << '\n';
   
   if(r < R) {
      int mn = R;
      dir_aint.const_walk([&](mnidx& a, int cl, int cr) { if(v[mn] > v[a.val]) mn = a.val; return 0;}, fallroot[R + 1], r + 1, R - 1);
      int mx = query_max(r + 1, mn - 1);
      if(mx - max(v[r], v[mn]) >= D) rez++;
   }
   
   return rez;
}
#undef int
# Verdict Execution time Memory Grader output
1 Correct 841 ms 1421136 KB Output is correct
2 Correct 1235 ms 1425856 KB Output is correct
3 Correct 1268 ms 1426056 KB Output is correct
4 Correct 1387 ms 1425744 KB Output is correct
5 Correct 1274 ms 1425824 KB Output is correct
6 Correct 1331 ms 1425948 KB Output is correct
7 Correct 1303 ms 1425912 KB Output is correct
8 Correct 417 ms 1410136 KB Output is correct
9 Correct 438 ms 1410388 KB Output is correct
10 Correct 420 ms 1410384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 432 ms 1410384 KB Output is correct
2 Correct 426 ms 1410640 KB Output is correct
3 Correct 483 ms 1410640 KB Output is correct
4 Correct 453 ms 1410480 KB Output is correct
5 Correct 425 ms 1410640 KB Output is correct
6 Correct 425 ms 1410640 KB Output is correct
7 Correct 447 ms 1410680 KB Output is correct
8 Correct 431 ms 1410384 KB Output is correct
9 Correct 474 ms 1410544 KB Output is correct
10 Correct 459 ms 1410396 KB Output is correct
11 Correct 451 ms 1410512 KB Output is correct
12 Correct 427 ms 1410236 KB Output is correct
13 Correct 455 ms 1410384 KB Output is correct
14 Correct 445 ms 1410384 KB Output is correct
15 Correct 440 ms 1410424 KB Output is correct
16 Correct 452 ms 1410500 KB Output is correct
17 Correct 433 ms 1410544 KB Output is correct
18 Correct 465 ms 1410496 KB Output is correct
19 Correct 453 ms 1410548 KB Output is correct
20 Correct 441 ms 1410636 KB Output is correct
21 Correct 444 ms 1410632 KB Output is correct
22 Correct 441 ms 1410640 KB Output is correct
23 Correct 438 ms 1410576 KB Output is correct
24 Correct 483 ms 1410428 KB Output is correct
25 Correct 472 ms 1410412 KB Output is correct
26 Correct 438 ms 1410516 KB Output is correct
27 Correct 422 ms 1410432 KB Output is correct
28 Correct 424 ms 1410612 KB Output is correct
29 Correct 417 ms 1410504 KB Output is correct
30 Correct 450 ms 1410612 KB Output is correct
31 Correct 478 ms 1410504 KB Output is correct
32 Correct 424 ms 1410564 KB Output is correct
33 Correct 434 ms 1410388 KB Output is correct
34 Correct 428 ms 1410616 KB Output is correct
35 Correct 409 ms 1410384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 432 ms 1410384 KB Output is correct
2 Correct 426 ms 1410640 KB Output is correct
3 Correct 483 ms 1410640 KB Output is correct
4 Correct 453 ms 1410480 KB Output is correct
5 Correct 425 ms 1410640 KB Output is correct
6 Correct 425 ms 1410640 KB Output is correct
7 Correct 447 ms 1410680 KB Output is correct
8 Correct 431 ms 1410384 KB Output is correct
9 Correct 474 ms 1410544 KB Output is correct
10 Correct 459 ms 1410396 KB Output is correct
11 Correct 451 ms 1410512 KB Output is correct
12 Correct 427 ms 1410236 KB Output is correct
13 Correct 455 ms 1410384 KB Output is correct
14 Correct 445 ms 1410384 KB Output is correct
15 Correct 440 ms 1410424 KB Output is correct
16 Correct 452 ms 1410500 KB Output is correct
17 Correct 433 ms 1410544 KB Output is correct
18 Correct 465 ms 1410496 KB Output is correct
19 Correct 453 ms 1410548 KB Output is correct
20 Correct 441 ms 1410636 KB Output is correct
21 Correct 444 ms 1410632 KB Output is correct
22 Correct 441 ms 1410640 KB Output is correct
23 Correct 438 ms 1410576 KB Output is correct
24 Correct 483 ms 1410428 KB Output is correct
25 Correct 472 ms 1410412 KB Output is correct
26 Correct 438 ms 1410516 KB Output is correct
27 Correct 422 ms 1410432 KB Output is correct
28 Correct 424 ms 1410612 KB Output is correct
29 Correct 417 ms 1410504 KB Output is correct
30 Correct 450 ms 1410612 KB Output is correct
31 Correct 478 ms 1410504 KB Output is correct
32 Correct 424 ms 1410564 KB Output is correct
33 Correct 434 ms 1410388 KB Output is correct
34 Correct 428 ms 1410616 KB Output is correct
35 Correct 409 ms 1410384 KB Output is correct
36 Correct 535 ms 1422112 KB Output is correct
37 Correct 599 ms 1428600 KB Output is correct
38 Correct 611 ms 1428728 KB Output is correct
39 Correct 739 ms 1430268 KB Output is correct
40 Correct 647 ms 1430100 KB Output is correct
41 Correct 648 ms 1430084 KB Output is correct
42 Correct 650 ms 1430120 KB Output is correct
43 Correct 535 ms 1425720 KB Output is correct
44 Correct 575 ms 1425888 KB Output is correct
45 Correct 551 ms 1425884 KB Output is correct
46 Correct 529 ms 1425908 KB Output is correct
47 Correct 617 ms 1428676 KB Output is correct
48 Correct 640 ms 1430332 KB Output is correct
49 Correct 639 ms 1430140 KB Output is correct
50 Correct 530 ms 1425816 KB Output is correct
51 Correct 555 ms 1425964 KB Output is correct
52 Correct 636 ms 1428812 KB Output is correct
53 Correct 646 ms 1430076 KB Output is correct
54 Correct 654 ms 1430076 KB Output is correct
55 Correct 534 ms 1425744 KB Output is correct
56 Correct 544 ms 1425924 KB Output is correct
57 Correct 602 ms 1428088 KB Output is correct
58 Correct 690 ms 1428624 KB Output is correct
59 Correct 606 ms 1428668 KB Output is correct
60 Correct 649 ms 1430096 KB Output is correct
61 Correct 629 ms 1430040 KB Output is correct
62 Correct 660 ms 1430080 KB Output is correct
63 Correct 669 ms 1430068 KB Output is correct
64 Correct 541 ms 1425888 KB Output is correct
65 Correct 564 ms 1425800 KB Output is correct
66 Correct 562 ms 1425932 KB Output is correct
67 Correct 525 ms 1425956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1472 ms 1428452 KB Output is correct
2 Correct 1629 ms 1428612 KB Output is correct
3 Correct 1578 ms 1428668 KB Output is correct
4 Correct 1617 ms 1430132 KB Output is correct
5 Correct 1562 ms 1430084 KB Output is correct
6 Correct 1582 ms 1430164 KB Output is correct
7 Correct 1564 ms 1430240 KB Output is correct
8 Correct 1220 ms 1425860 KB Output is correct
9 Correct 1233 ms 1426032 KB Output is correct
10 Correct 2150 ms 1425880 KB Output is correct
11 Correct 2484 ms 1425744 KB Output is correct
12 Correct 1209 ms 1425744 KB Output is correct
13 Correct 1280 ms 1425764 KB Output is correct
14 Correct 397 ms 1410208 KB Output is correct
15 Correct 402 ms 1410516 KB Output is correct
16 Correct 399 ms 1410384 KB Output is correct
17 Correct 596 ms 1428620 KB Output is correct
18 Correct 622 ms 1430080 KB Output is correct
19 Correct 656 ms 1430064 KB Output is correct
20 Correct 535 ms 1425744 KB Output is correct
21 Correct 560 ms 1425884 KB Output is correct
22 Correct 591 ms 1428668 KB Output is correct
23 Correct 632 ms 1430116 KB Output is correct
24 Correct 633 ms 1430080 KB Output is correct
25 Correct 522 ms 1425824 KB Output is correct
26 Correct 724 ms 1425800 KB Output is correct
27 Correct 415 ms 1410640 KB Output is correct
28 Correct 405 ms 1410640 KB Output is correct
29 Correct 452 ms 1410584 KB Output is correct
30 Correct 408 ms 1410384 KB Output is correct
31 Correct 406 ms 1410604 KB Output is correct
32 Correct 404 ms 1410640 KB Output is correct
33 Correct 404 ms 1410640 KB Output is correct
34 Correct 409 ms 1410624 KB Output is correct
35 Correct 408 ms 1410512 KB Output is correct
36 Correct 403 ms 1410484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 693 ms 1414736 KB Output is correct
2 Correct 1372 ms 1428672 KB Output is correct
3 Correct 1349 ms 1428668 KB Output is correct
4 Correct 1401 ms 1430080 KB Output is correct
5 Correct 1483 ms 1430192 KB Output is correct
6 Correct 1431 ms 1430080 KB Output is correct
7 Correct 1404 ms 1430080 KB Output is correct
8 Correct 1233 ms 1425920 KB Output is correct
9 Execution timed out 4099 ms 1425884 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 432 ms 1410384 KB Output is correct
2 Correct 426 ms 1410640 KB Output is correct
3 Correct 483 ms 1410640 KB Output is correct
4 Correct 453 ms 1410480 KB Output is correct
5 Correct 425 ms 1410640 KB Output is correct
6 Correct 425 ms 1410640 KB Output is correct
7 Correct 447 ms 1410680 KB Output is correct
8 Correct 431 ms 1410384 KB Output is correct
9 Correct 474 ms 1410544 KB Output is correct
10 Correct 459 ms 1410396 KB Output is correct
11 Correct 451 ms 1410512 KB Output is correct
12 Correct 427 ms 1410236 KB Output is correct
13 Correct 455 ms 1410384 KB Output is correct
14 Correct 445 ms 1410384 KB Output is correct
15 Correct 440 ms 1410424 KB Output is correct
16 Correct 452 ms 1410500 KB Output is correct
17 Correct 433 ms 1410544 KB Output is correct
18 Correct 465 ms 1410496 KB Output is correct
19 Correct 453 ms 1410548 KB Output is correct
20 Correct 441 ms 1410636 KB Output is correct
21 Correct 444 ms 1410632 KB Output is correct
22 Correct 441 ms 1410640 KB Output is correct
23 Correct 438 ms 1410576 KB Output is correct
24 Correct 483 ms 1410428 KB Output is correct
25 Correct 472 ms 1410412 KB Output is correct
26 Correct 438 ms 1410516 KB Output is correct
27 Correct 422 ms 1410432 KB Output is correct
28 Correct 424 ms 1410612 KB Output is correct
29 Correct 417 ms 1410504 KB Output is correct
30 Correct 450 ms 1410612 KB Output is correct
31 Correct 478 ms 1410504 KB Output is correct
32 Correct 424 ms 1410564 KB Output is correct
33 Correct 434 ms 1410388 KB Output is correct
34 Correct 428 ms 1410616 KB Output is correct
35 Correct 409 ms 1410384 KB Output is correct
36 Correct 535 ms 1422112 KB Output is correct
37 Correct 599 ms 1428600 KB Output is correct
38 Correct 611 ms 1428728 KB Output is correct
39 Correct 739 ms 1430268 KB Output is correct
40 Correct 647 ms 1430100 KB Output is correct
41 Correct 648 ms 1430084 KB Output is correct
42 Correct 650 ms 1430120 KB Output is correct
43 Correct 535 ms 1425720 KB Output is correct
44 Correct 575 ms 1425888 KB Output is correct
45 Correct 551 ms 1425884 KB Output is correct
46 Correct 529 ms 1425908 KB Output is correct
47 Correct 617 ms 1428676 KB Output is correct
48 Correct 640 ms 1430332 KB Output is correct
49 Correct 639 ms 1430140 KB Output is correct
50 Correct 530 ms 1425816 KB Output is correct
51 Correct 555 ms 1425964 KB Output is correct
52 Correct 636 ms 1428812 KB Output is correct
53 Correct 646 ms 1430076 KB Output is correct
54 Correct 654 ms 1430076 KB Output is correct
55 Correct 534 ms 1425744 KB Output is correct
56 Correct 544 ms 1425924 KB Output is correct
57 Correct 602 ms 1428088 KB Output is correct
58 Correct 690 ms 1428624 KB Output is correct
59 Correct 606 ms 1428668 KB Output is correct
60 Correct 649 ms 1430096 KB Output is correct
61 Correct 629 ms 1430040 KB Output is correct
62 Correct 660 ms 1430080 KB Output is correct
63 Correct 669 ms 1430068 KB Output is correct
64 Correct 541 ms 1425888 KB Output is correct
65 Correct 564 ms 1425800 KB Output is correct
66 Correct 562 ms 1425932 KB Output is correct
67 Correct 525 ms 1425956 KB Output is correct
68 Correct 1472 ms 1428452 KB Output is correct
69 Correct 1629 ms 1428612 KB Output is correct
70 Correct 1578 ms 1428668 KB Output is correct
71 Correct 1617 ms 1430132 KB Output is correct
72 Correct 1562 ms 1430084 KB Output is correct
73 Correct 1582 ms 1430164 KB Output is correct
74 Correct 1564 ms 1430240 KB Output is correct
75 Correct 1220 ms 1425860 KB Output is correct
76 Correct 1233 ms 1426032 KB Output is correct
77 Correct 2150 ms 1425880 KB Output is correct
78 Correct 2484 ms 1425744 KB Output is correct
79 Correct 1209 ms 1425744 KB Output is correct
80 Correct 1280 ms 1425764 KB Output is correct
81 Correct 397 ms 1410208 KB Output is correct
82 Correct 402 ms 1410516 KB Output is correct
83 Correct 399 ms 1410384 KB Output is correct
84 Correct 596 ms 1428620 KB Output is correct
85 Correct 622 ms 1430080 KB Output is correct
86 Correct 656 ms 1430064 KB Output is correct
87 Correct 535 ms 1425744 KB Output is correct
88 Correct 560 ms 1425884 KB Output is correct
89 Correct 591 ms 1428668 KB Output is correct
90 Correct 632 ms 1430116 KB Output is correct
91 Correct 633 ms 1430080 KB Output is correct
92 Correct 522 ms 1425824 KB Output is correct
93 Correct 724 ms 1425800 KB Output is correct
94 Correct 415 ms 1410640 KB Output is correct
95 Correct 405 ms 1410640 KB Output is correct
96 Correct 452 ms 1410584 KB Output is correct
97 Correct 408 ms 1410384 KB Output is correct
98 Correct 406 ms 1410604 KB Output is correct
99 Correct 404 ms 1410640 KB Output is correct
100 Correct 404 ms 1410640 KB Output is correct
101 Correct 409 ms 1410624 KB Output is correct
102 Correct 408 ms 1410512 KB Output is correct
103 Correct 403 ms 1410484 KB Output is correct
104 Correct 1468 ms 1426564 KB Output is correct
105 Correct 1710 ms 1428720 KB Output is correct
106 Correct 1736 ms 1430460 KB Output is correct
107 Correct 1712 ms 1430080 KB Output is correct
108 Incorrect 1823 ms 1430064 KB 19976th lines differ - on the 1st token, expected: '2', found: '1'
109 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 841 ms 1421136 KB Output is correct
2 Correct 1235 ms 1425856 KB Output is correct
3 Correct 1268 ms 1426056 KB Output is correct
4 Correct 1387 ms 1425744 KB Output is correct
5 Correct 1274 ms 1425824 KB Output is correct
6 Correct 1331 ms 1425948 KB Output is correct
7 Correct 1303 ms 1425912 KB Output is correct
8 Correct 417 ms 1410136 KB Output is correct
9 Correct 438 ms 1410388 KB Output is correct
10 Correct 420 ms 1410384 KB Output is correct
11 Correct 432 ms 1410384 KB Output is correct
12 Correct 426 ms 1410640 KB Output is correct
13 Correct 483 ms 1410640 KB Output is correct
14 Correct 453 ms 1410480 KB Output is correct
15 Correct 425 ms 1410640 KB Output is correct
16 Correct 425 ms 1410640 KB Output is correct
17 Correct 447 ms 1410680 KB Output is correct
18 Correct 431 ms 1410384 KB Output is correct
19 Correct 474 ms 1410544 KB Output is correct
20 Correct 459 ms 1410396 KB Output is correct
21 Correct 451 ms 1410512 KB Output is correct
22 Correct 427 ms 1410236 KB Output is correct
23 Correct 455 ms 1410384 KB Output is correct
24 Correct 445 ms 1410384 KB Output is correct
25 Correct 440 ms 1410424 KB Output is correct
26 Correct 452 ms 1410500 KB Output is correct
27 Correct 433 ms 1410544 KB Output is correct
28 Correct 465 ms 1410496 KB Output is correct
29 Correct 453 ms 1410548 KB Output is correct
30 Correct 441 ms 1410636 KB Output is correct
31 Correct 444 ms 1410632 KB Output is correct
32 Correct 441 ms 1410640 KB Output is correct
33 Correct 438 ms 1410576 KB Output is correct
34 Correct 483 ms 1410428 KB Output is correct
35 Correct 472 ms 1410412 KB Output is correct
36 Correct 438 ms 1410516 KB Output is correct
37 Correct 422 ms 1410432 KB Output is correct
38 Correct 424 ms 1410612 KB Output is correct
39 Correct 417 ms 1410504 KB Output is correct
40 Correct 450 ms 1410612 KB Output is correct
41 Correct 478 ms 1410504 KB Output is correct
42 Correct 424 ms 1410564 KB Output is correct
43 Correct 434 ms 1410388 KB Output is correct
44 Correct 428 ms 1410616 KB Output is correct
45 Correct 409 ms 1410384 KB Output is correct
46 Correct 535 ms 1422112 KB Output is correct
47 Correct 599 ms 1428600 KB Output is correct
48 Correct 611 ms 1428728 KB Output is correct
49 Correct 739 ms 1430268 KB Output is correct
50 Correct 647 ms 1430100 KB Output is correct
51 Correct 648 ms 1430084 KB Output is correct
52 Correct 650 ms 1430120 KB Output is correct
53 Correct 535 ms 1425720 KB Output is correct
54 Correct 575 ms 1425888 KB Output is correct
55 Correct 551 ms 1425884 KB Output is correct
56 Correct 529 ms 1425908 KB Output is correct
57 Correct 617 ms 1428676 KB Output is correct
58 Correct 640 ms 1430332 KB Output is correct
59 Correct 639 ms 1430140 KB Output is correct
60 Correct 530 ms 1425816 KB Output is correct
61 Correct 555 ms 1425964 KB Output is correct
62 Correct 636 ms 1428812 KB Output is correct
63 Correct 646 ms 1430076 KB Output is correct
64 Correct 654 ms 1430076 KB Output is correct
65 Correct 534 ms 1425744 KB Output is correct
66 Correct 544 ms 1425924 KB Output is correct
67 Correct 602 ms 1428088 KB Output is correct
68 Correct 690 ms 1428624 KB Output is correct
69 Correct 606 ms 1428668 KB Output is correct
70 Correct 649 ms 1430096 KB Output is correct
71 Correct 629 ms 1430040 KB Output is correct
72 Correct 660 ms 1430080 KB Output is correct
73 Correct 669 ms 1430068 KB Output is correct
74 Correct 541 ms 1425888 KB Output is correct
75 Correct 564 ms 1425800 KB Output is correct
76 Correct 562 ms 1425932 KB Output is correct
77 Correct 525 ms 1425956 KB Output is correct
78 Correct 1472 ms 1428452 KB Output is correct
79 Correct 1629 ms 1428612 KB Output is correct
80 Correct 1578 ms 1428668 KB Output is correct
81 Correct 1617 ms 1430132 KB Output is correct
82 Correct 1562 ms 1430084 KB Output is correct
83 Correct 1582 ms 1430164 KB Output is correct
84 Correct 1564 ms 1430240 KB Output is correct
85 Correct 1220 ms 1425860 KB Output is correct
86 Correct 1233 ms 1426032 KB Output is correct
87 Correct 2150 ms 1425880 KB Output is correct
88 Correct 2484 ms 1425744 KB Output is correct
89 Correct 1209 ms 1425744 KB Output is correct
90 Correct 1280 ms 1425764 KB Output is correct
91 Correct 397 ms 1410208 KB Output is correct
92 Correct 402 ms 1410516 KB Output is correct
93 Correct 399 ms 1410384 KB Output is correct
94 Correct 596 ms 1428620 KB Output is correct
95 Correct 622 ms 1430080 KB Output is correct
96 Correct 656 ms 1430064 KB Output is correct
97 Correct 535 ms 1425744 KB Output is correct
98 Correct 560 ms 1425884 KB Output is correct
99 Correct 591 ms 1428668 KB Output is correct
100 Correct 632 ms 1430116 KB Output is correct
101 Correct 633 ms 1430080 KB Output is correct
102 Correct 522 ms 1425824 KB Output is correct
103 Correct 724 ms 1425800 KB Output is correct
104 Correct 415 ms 1410640 KB Output is correct
105 Correct 405 ms 1410640 KB Output is correct
106 Correct 452 ms 1410584 KB Output is correct
107 Correct 408 ms 1410384 KB Output is correct
108 Correct 406 ms 1410604 KB Output is correct
109 Correct 404 ms 1410640 KB Output is correct
110 Correct 404 ms 1410640 KB Output is correct
111 Correct 409 ms 1410624 KB Output is correct
112 Correct 408 ms 1410512 KB Output is correct
113 Correct 403 ms 1410484 KB Output is correct
114 Correct 693 ms 1414736 KB Output is correct
115 Correct 1372 ms 1428672 KB Output is correct
116 Correct 1349 ms 1428668 KB Output is correct
117 Correct 1401 ms 1430080 KB Output is correct
118 Correct 1483 ms 1430192 KB Output is correct
119 Correct 1431 ms 1430080 KB Output is correct
120 Correct 1404 ms 1430080 KB Output is correct
121 Correct 1233 ms 1425920 KB Output is correct
122 Execution timed out 4099 ms 1425884 KB Time limit exceeded
123 Halted 0 ms 0 KB -