답안 #654486

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654486 2022-10-31T13:23:40 Z Rafi22 L-triominoes (CEOI21_ltriominoes) C++14
10 / 100
1108 ms 9776 KB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;

const int N=(1<<13)+7;

set<int>G[N];
bool DP[N],nDP[N];
int n,m,k;

void bt(int x,int p,int i,int y)
{
    int X=x|p;
    if(i==n)
    {
        if(X!=(1<<n)-1) return ;
        G[x].insert(y);
        return ;
    }
    bt(x,p,i+1,y);
    if(i<n-1)
    {
        if(!(X&(1<<i))&&!(X&(1<<(i+1)))&&!(y&(1<<(i+1)))) bt(x,p|(1<<i)|(1<<(i+1)),i+1,y|(1<<(i+1)));
        if(!(X&(1<<i))&&!(X&(1<<(i+1)))&&!(y&(1<<i))) bt(x,p|(1<<i)|(1<<(i+1)),i+1,y|(1<<i));
        if(!(X&(1<<i))&&!(y&(1<<(i+1)))&&!(y&(1<<i))) bt(x,p|(1<<i),i+1,y|(1<<i)|(1<<(i+1)));
    }
    if(i>0&&!(X&(1<<i))&&!(y&(1<<(i-1)))&&!(y&(1<<i))) bt(x,p|(1<<i),i+1,y|(1<<i)|(1<<(i-1)));
}

set<int>S;
map<int,vector<int>>M;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k;
    for(int i=0;i<(1<<n);i++) bt(i,0,0,0);
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin>>x>>y;
        S.insert(y);
        M[y].pb(x);
    }
    S.insert(m);
    DP[0]=1;
    int l=1;
    for(auto p:S)
    {
        int X=0;
        for(auto c:M[p]) X|=(1<<(c-1));
        if(p-l>15)
        {
            vector<bool>is(3,0);
            for(int i=0;i<(1<<n);i++)
            {
                if(DP[i]) is[__builtin_popcount(i)%3]=1;
            }
            for(int i=0;i<(1<<n);i++)
            {
                if(is[((p-l)*n+__builtin_popcount(i))%3]) DP[i]=1;
                else DP[i]=0;
            }
        }
        else
        {
            for(int j=0;j<p-l;j++)
            {
                memset(nDP,0,sizeof nDP);
                for(int i=0; i<(1<<n); i++)
                {
                    if(!DP[i]) continue;
                    for(auto x:G[i]) nDP[x]=1;
                }
                for(int i=0;i<(1<<n);i++) DP[i]=nDP[i];
            }
        }
        memset(nDP,0,sizeof nDP);
        for(int i=0;i<(1<<n);i++)
        {
            if(DP[i]&&!(i&X)) nDP[i|X]=1;
        }
        for(int i=0;i<(1<<n);i++) DP[i]=nDP[i];
        l=p;
    }
    if(DP[(1<<n)-1]) cout<<"YES";
    else cout<<"NO";


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 708 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 71 ms 4032 KB Output is correct
9 Correct 21 ms 1992 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
11 Correct 69 ms 4000 KB Output is correct
12 Correct 6 ms 1092 KB Output is correct
13 Correct 1 ms 724 KB Output is correct
14 Correct 1 ms 712 KB Output is correct
15 Correct 72 ms 4100 KB Output is correct
16 Correct 1108 ms 9692 KB Output is correct
17 Correct 12 ms 1280 KB Output is correct
18 Correct 259 ms 4024 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 740 ms 9776 KB Output is correct
21 Correct 206 ms 4112 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 2 ms 708 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 366 ms 9660 KB Output is correct
26 Correct 608 ms 9548 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Runtime error 1 ms 1236 KB Execution killed with signal 7
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 712 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 712 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 1 ms 724 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 1 ms 724 KB Output is correct
14 Correct 1 ms 712 KB Output is correct
15 Correct 1 ms 724 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 1 ms 724 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Runtime error 2 ms 1364 KB Execution killed with signal 7
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 708 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 75 ms 4164 KB Output is correct
5 Correct 23 ms 1988 KB Output is correct
6 Correct 24 ms 1940 KB Output is correct
7 Correct 7 ms 1108 KB Output is correct
8 Correct 8 ms 1108 KB Output is correct
9 Runtime error 7 ms 2260 KB Execution killed with signal 7
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 708 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 71 ms 4032 KB Output is correct
9 Correct 21 ms 1992 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
11 Correct 69 ms 4000 KB Output is correct
12 Correct 6 ms 1092 KB Output is correct
13 Correct 1 ms 724 KB Output is correct
14 Correct 1 ms 712 KB Output is correct
15 Correct 72 ms 4100 KB Output is correct
16 Correct 1108 ms 9692 KB Output is correct
17 Correct 12 ms 1280 KB Output is correct
18 Correct 259 ms 4024 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 740 ms 9776 KB Output is correct
21 Correct 206 ms 4112 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 2 ms 708 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 366 ms 9660 KB Output is correct
26 Correct 608 ms 9548 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Incorrect 1 ms 724 KB Output isn't correct
29 Halted 0 ms 0 KB -