Submission #983491

# Submission time Handle Problem Language Result Execution time Memory
983491 2024-05-15T15:02:28 Z AdamGS Card Collection (JOI24_collection) C++17
49 / 100
4000 ms 8324 KB
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e5+7;
pair<int,int>T[LIM];
int czy[LIM], n;
vector<int>pref(vector<pair<int,int>>P, int a, int b) {
  vector<int>ans(3);
  if(P.size()==0) ans[2]=1;
  rep(i, P.size()) {
    bool zero=false, jeden=false, dwa=false;
    if(P[i].st>=a && P[i].nd>=b) dwa=true;
    if(P[i].st<=a && P[i].nd<=b) dwa=true;
    if(P[i].st<=a && P[i].nd>=b) zero=true;
    if(P[i].st>=a && P[i].nd<=b) jeden=true;
    if(ans[0]+ans[1]+ans[2]==0) {
      if(zero) ans[0]=1;
      if(jeden) ans[1]=1;
      if(dwa) ans[2]=1;
      continue;
    }
    if(!ans[2]) {
      if(ans[0] && jeden) ans[2]=1;
      if(ans[1] && zero) ans[2]=1;
      if(dwa) ans[2]=1;
      continue;
    }
    if(zero) ans[0]=1;
    if(jeden) ans[1]=1;
    if(dwa) ans[2]=1;
  }
  return ans;
}
vector<int>nxt(vector<int>A, vector<int>B) {
  vector<int>ans(2);
  ans[0]=B[0]|(A[0]&B[2]);
  ans[1]=B[1]|(A[1]&B[2]);
  return ans;
}
bool solve(int a, int b) {
  rep(i, n) if(T[i].st==a) {
    for(int j=n-1; j>i; --j) if(T[j].nd==b) {
      vector<int>A(3);
      for(int l=i+1; l<j; ++l) {
        if(T[l].st>=a && T[l].nd>=b) A[2]=1;
        if(T[l].st<=a && T[l].nd<=b) A[2]=1;
        if(T[l].st<=a && T[l].nd>=b) A[0]=1;
        if(T[l].st>=a && T[l].nd<=b) A[1]=1;
      }
      if(A[0] && A[1]) return true;
      if(A[0]+A[1]+A[2]==0) A[2]=1;
      vector<pair<int,int>>P;
      for(int l=0; l<i; ++l) P.pb(T[l]);
      vector<int>B=pref(P, a, b);
      P.clear();
      for(int l=n-1; l>j; --l) P.pb(T[l]);
      vector<int>C=pref(P, a, b);
      vector<int>X(2), Y(2);
      if(T[i].nd>=b) X[0]=1;
      if(T[i].nd<=b) X[1]=1;
      if(T[j].st<=a) Y[0]=1;
      if(T[j].st>=a) Y[1]=1;
      vector<int>D=X, E=Y;
      D=nxt(D, B);
      D=nxt(D, A);
      E=nxt(E, C);
      if(D[0] && E[1] || D[1] && E[0]) return true;
      D=X; E=Y;
      D=nxt(D, A);
      D=nxt(D, B);
      E=nxt(E, C);
      if(D[0] && E[1] || D[1] && E[0]) return true;
      D=X; E=Y;
      D=nxt(D, B);
      E=nxt(E, C);
      E=nxt(E, A);
      if(D[0] && E[1] || D[1] && E[0]) return true;
      D=X; E=Y;
      D=nxt(D, B);
      E=nxt(E, A);
      E=nxt(E, C);
      if(D[0] && E[1] || D[1] && E[0]) return true;
      break;
    }
    break;
  }
  rep(i, n) if(T[i].nd==b) {
    for(int j=n-1; j>i; --j) if(T[j].st==a) {
      vector<int>A(3);
      for(int l=i+1; l<j; ++l) {
        if(T[l].st>=a && T[l].nd>=b) A[2]=1;
        if(T[l].st<=a && T[l].nd<=b) A[2]=1;
        if(T[l].st<=a && T[l].nd>=b) A[0]=1;
        if(T[l].st>=a && T[l].nd<=b) A[1]=1;
      }
      if(A[0] && A[1]) return true;
      if(A[0]+A[1]+A[2]==0) A[2]=1;
      vector<pair<int,int>>P;
      for(int l=0; l<i; ++l) P.pb(T[l]);
      vector<int>B=pref(P, a, b);
      P.clear();
      for(int l=n-1; l>j; --l) P.pb(T[l]);
      vector<int>C=pref(P, a, b);
      vector<int>X(2), Y(2);
      if(T[j].nd>=b) Y[0]=1;
      if(T[j].nd<=b) Y[1]=1;
      if(T[i].st<=a) X[0]=1;
      if(T[i].st>=a) X[1]=1;
      vector<int>D=X, E=Y;
      D=nxt(D, B);
      D=nxt(D, A);
      E=nxt(E, C);
      if(D[0] && E[1] || D[1] && E[0]) return true;
      D=X; E=Y;
      D=nxt(D, A);
      D=nxt(D, B);
      E=nxt(E, C);
      if(D[0] && E[1] || D[1] && E[0]) return true;
      D=X; E=Y;
      D=nxt(D, B);
      E=nxt(E, C);
      E=nxt(E, A);
      if(D[0] && E[1] || D[1] && E[0]) return true;
      D=X; E=Y;
      D=nxt(D, B);
      E=nxt(E, A);
      E=nxt(E, C);
      if(D[0] && E[1] || D[1] && E[0]) return true;
      break;
    }
  }
  rep(i, n) if(T[i].st==a && T[i].nd==b) {
    vector<pair<int,int>>P;
    for(int j=0; j<i; ++j) P.pb(T[j]);
    vector<int>A=pref(P, a, b);
    P.clear();
    for(int j=n-1; j>i; --j) P.pb(T[j]);
    vector<int>B=pref(P, a, b);
    if(A[2] && B[2]) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int m;
  cin >> n >> m;
  rep(i, n) cin >> T[i].st >> T[i].nd;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    if(solve(a, b)) cout << i+1 << " ";
  }
  cout << '\n';
}

Compilation message

Main.cpp: In function 'std::vector<int> pref(std::vector<std::pair<int, int> >, int, int)':
Main.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
Main.cpp:16:3: note: in expansion of macro 'rep'
   16 |   rep(i, P.size()) {
      |   ^~~
Main.cpp: In function 'bool solve(int, int)':
Main.cpp:73:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   73 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:78:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   78 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:83:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   83 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:88:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   88 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:119:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  119 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:124:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  124 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:129:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  129 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:134:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  134 |       if(D[0] && E[1] || D[1] && E[0]) return true;
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2648 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2404 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2516 KB Output is correct
29 Correct 0 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2512 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2648 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2404 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2516 KB Output is correct
29 Correct 0 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2512 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2648 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 2 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2392 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2392 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2392 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 1 ms 2520 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 1 ms 2392 KB Output is correct
66 Correct 1 ms 2396 KB Output is correct
67 Correct 1 ms 2396 KB Output is correct
68 Correct 1 ms 2392 KB Output is correct
69 Correct 1 ms 2396 KB Output is correct
70 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2648 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2404 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2516 KB Output is correct
29 Correct 0 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2512 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2648 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 2 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2392 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2392 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2392 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 1 ms 2520 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 1 ms 2392 KB Output is correct
66 Correct 1 ms 2396 KB Output is correct
67 Correct 1 ms 2396 KB Output is correct
68 Correct 1 ms 2392 KB Output is correct
69 Correct 1 ms 2396 KB Output is correct
70 Correct 1 ms 2392 KB Output is correct
71 Correct 26 ms 4956 KB Output is correct
72 Correct 27 ms 5208 KB Output is correct
73 Correct 30 ms 4956 KB Output is correct
74 Correct 32 ms 4180 KB Output is correct
75 Correct 34 ms 3696 KB Output is correct
76 Correct 37 ms 3152 KB Output is correct
77 Correct 32 ms 2652 KB Output is correct
78 Correct 35 ms 2644 KB Output is correct
79 Correct 36 ms 3664 KB Output is correct
80 Correct 35 ms 4260 KB Output is correct
81 Correct 36 ms 3880 KB Output is correct
82 Correct 38 ms 3744 KB Output is correct
83 Correct 47 ms 8276 KB Output is correct
84 Correct 52 ms 8324 KB Output is correct
85 Correct 33 ms 8224 KB Output is correct
86 Correct 40 ms 4696 KB Output is correct
87 Execution timed out 4030 ms 5208 KB Time limit exceeded
88 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2648 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2404 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2516 KB Output is correct
29 Correct 0 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2512 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2648 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 2 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2392 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2392 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2392 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 1 ms 2520 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 1 ms 2392 KB Output is correct
66 Correct 1 ms 2396 KB Output is correct
67 Correct 1 ms 2396 KB Output is correct
68 Correct 1 ms 2392 KB Output is correct
69 Correct 1 ms 2396 KB Output is correct
70 Correct 1 ms 2392 KB Output is correct
71 Correct 26 ms 4956 KB Output is correct
72 Correct 27 ms 5208 KB Output is correct
73 Correct 30 ms 4956 KB Output is correct
74 Correct 32 ms 4180 KB Output is correct
75 Correct 34 ms 3696 KB Output is correct
76 Correct 37 ms 3152 KB Output is correct
77 Correct 32 ms 2652 KB Output is correct
78 Correct 35 ms 2644 KB Output is correct
79 Correct 36 ms 3664 KB Output is correct
80 Correct 35 ms 4260 KB Output is correct
81 Correct 36 ms 3880 KB Output is correct
82 Correct 38 ms 3744 KB Output is correct
83 Correct 47 ms 8276 KB Output is correct
84 Correct 52 ms 8324 KB Output is correct
85 Correct 33 ms 8224 KB Output is correct
86 Correct 40 ms 4696 KB Output is correct
87 Execution timed out 4030 ms 5208 KB Time limit exceeded
88 Halted 0 ms 0 KB -