Submission #660555

# Submission time Handle Problem Language Result Execution time Memory
660555 2022-11-22T09:40:53 Z 600Mihnea trapezoid (balkan11_trapezoid) C++17
0 / 100
41 ms 65536 KB
bool home = 0;

#include <bits/stdc++.h>

using namespace std;

const int MODULO = 30013;

struct T
{
  int a;
  int b;
  int c;
  int d;
};

bool operator < (T first, T second)
{
  return first.b < second.b;
}

int main()
{
  if (home == 0)
  {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen ("trapezoid.in", "r", stdin);
    freopen ("trapezoid.out", "w", stdout);
  }
  else
  {
    freopen ("input.txt", "r", stdin);
  }

  int n;
  cin >> n;
  vector<T> v(n);

  for (auto &it : v)
  {
    cin >> it.a >> it.b >> it.c >> it.d;
  }
  sort(v.begin(), v.end());
  vector<int> dp(n, 0), ways(n, 0);
  for (int i = 0; i < n; i++)
  {
    dp[i] = 1;
    ways[i] = 1;

    for (int j = 0; j < i; j++)
    {
      if (v[j].b < v[i].a && v[j].d < v[i].c)
      {
        if (dp[j] + 1 > dp[i])
        {
          dp[i] = dp[j] + 1;
          ways[i] = ways[j];
        }
        else
        {
          if (dp[j] + 1 == dp[i])
          {
            ways[i] = (ways[i] + ways[j]) % MODULO;
          }
        }
      }
    }
  }
  int mx = *max_element(dp.begin(), dp.end()), cnt = 0;
  for (int i = 0; i < n; i++)
  {
    if (dp[i] == mx)
    {
      cnt = (cnt + ways[i]) % MODULO;
    }
  }
  cout << mx << " " << cnt << "\n";
  return 0;
}

Compilation message

trapezoid.cpp: In function 'int main()':
trapezoid.cpp:27:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen ("trapezoid.in", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
trapezoid.cpp:28:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     freopen ("trapezoid.out", "w", stdout);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trapezoid.cpp:32:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen ("input.txt", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 37 ms 65536 KB Execution killed with signal 9
2 Runtime error 2 ms 596 KB Execution killed with signal 6
3 Runtime error 2 ms 596 KB Execution killed with signal 6
4 Runtime error 3 ms 596 KB Execution killed with signal 6
5 Runtime error 3 ms 468 KB Execution killed with signal 6
6 Runtime error 2 ms 596 KB Execution killed with signal 6
7 Runtime error 38 ms 65536 KB Execution killed with signal 9
8 Runtime error 2 ms 596 KB Execution killed with signal 6
9 Runtime error 40 ms 65536 KB Execution killed with signal 9
10 Runtime error 41 ms 65536 KB Execution killed with signal 9
11 Runtime error 39 ms 65536 KB Execution killed with signal 9
12 Runtime error 40 ms 65536 KB Execution killed with signal 9
13 Runtime error 3 ms 596 KB Execution killed with signal 6
14 Runtime error 2 ms 596 KB Execution killed with signal 6
15 Runtime error 2 ms 596 KB Execution killed with signal 6
16 Runtime error 2 ms 596 KB Execution killed with signal 6
17 Runtime error 3 ms 596 KB Execution killed with signal 6
18 Runtime error 2 ms 596 KB Execution killed with signal 6
19 Runtime error 2 ms 596 KB Execution killed with signal 6
20 Runtime error 2 ms 596 KB Execution killed with signal 6