This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin >> n >> m;
vector<pair<int,int>> cards(n+1);
for(int i=1;i<=n;i++)cin>>cards[i].first>>cards[i].second;
for(int i=1;i<=m;i++) {
int tara,tarb;cin>>tara>>tarb;
vector DP(n+1,vector(n+1,vector(3,vector(3,false))));
for(int j=n;j;j--) {
int mya = 1;
if(cards[j].first>tara)mya=2;
else if(cards[j].first<tara)mya=0;
int myb = 1;
if(cards[j].second>tarb)myb=2;
else if(cards[j].second<tarb)myb=0;
DP[j][j][mya][myb]=true;
for(int r=j+1;r<=n;r++) {
for(int x=j;x<r;x++) {
for(int k=0;k<3;k++) {
for(int l=0;l<3;l++) {
for(int f=0;f<=k;f++) {
for(int g=0;g<=l;g++) {
if(DP[j][x][k][g] and DP[x+1][r][f][l])DP[j][r][k][l]=true;
if(DP[j][x][k][l] and DP[x+1][r][f][g])DP[j][r][k][l]=true;
if(DP[j][x][f][g] and DP[x+1][r][k][l])DP[j][r][k][l]=true;
if(DP[j][x][f][l] and DP[x+1][r][k][g])DP[j][r][k][l]=true;
}
}
for(int f=k;f<3;f++) {
for(int g=l;g<3;g++) {
if(DP[j][x][k][g] and DP[x+1][r][f][l])DP[j][r][k][l]=true;
if(DP[j][x][k][l] and DP[x+1][r][f][g])DP[j][r][k][l]=true;
if(DP[j][x][f][g] and DP[x+1][r][k][l])DP[j][r][k][l]=true;
if(DP[j][x][f][l] and DP[x+1][r][k][g])DP[j][r][k][l]=true;
}
}
}
}
}
}
}
if(DP[1][n][1][1])cout<<i<<' ';
}
cout << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |