Submission #983491

#TimeUsernameProblemLanguageResultExecution timeMemory
983491AdamGSCard Collection (JOI24_collection)C++17
49 / 100
4030 ms8324 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(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 (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: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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...