Submission #983484

#TimeUsernameProblemLanguageResultExecution timeMemory
983484AdamGSCard Collection (JOI24_collection)C++17
0 / 100
1 ms2396 KiB
#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(dwa) ans[2]=1; if(ans[2] && zero) ans[0]=1; if(ans[2] && jeden) ans[1]=1; if(ans[2]==0 && ans[1]==0 && zero) ans[0]=1; if(ans[2]==0 && ans[0]==0 && jeden) ans[1]=1; if(ans[2]==0 && ans[1]==1 && zero) ans[2]=1; if(ans[2]==0 && ans[0]==1 && jeden) 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; 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) X[0]=1; if(T[j].nd<=b) X[1]=1; if(T[i].st<=a) Y[0]=1; if(T[i].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; } } 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 (stderr)

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:64:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   64 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:69:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   69 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:74:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   74 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:79:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   79 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:110:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  110 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:115:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  115 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:120:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  120 |       if(D[0] && E[1] || D[1] && E[0]) return true;
Main.cpp:125:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  125 |       if(D[0] && E[1] || D[1] && E[0]) return true;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...