QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#459415#8830. Breaking Baducup-team1134#WA 605ms8748kbC++232.9kb2024-06-30 03:29:252024-06-30 03:29:26

Judging History

你现在查看的是最新测评结果

  • [2024-06-30 03:29:26]
  • 评测
  • 测评结果:WA
  • 用时:605ms
  • 内存:8748kb
  • [2024-06-30 03:29:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;

bool dp[1005][1<<10][5];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
    clock_t start,endd;
        start=clock();
    
    int N;cin>>N;
    map<vector<int>,int> MA;
    int def=0;
    for(int i=0;i<N;i++){
        vector<int> A(N);
        for(int j=0;j<N;j++){
            cin>>A[j];
        }
        for(int j=1;j<N;j++){
            A[j]-=A[0];
            if(A[j]<0) A[j]+=5;
        }
        def+=A[0];
        A[0]=0;
        MA[A]++;
    }
    
    vector<vector<int>> S,T;
    
    for(auto [X,cn]:MA){
        int K=min({5,45-si(S),cn});
        for(int t=0;t<K;t++) S.push_back(X);
        for(int t=0;t<cn-K;t++) T.push_back(X);
    }
    
    vector<int> ans(5);
    
    while(1){
        endd=clock();
        
        const double time=static_cast<double>(endd-start)/CLOCKS_PER_SEC*1000.0;
        
        if(time>=600) break;
        
        shuffle(all(S),rng);
        
        int K=min(10,si(S));
        memset(dp,0,sizeof(dp));
        
        dp[0][0][def]=true;
        
        for(int j=0;j<N;j++){
            for(int i=0;i<(1<<K);i++){
                int s=j-__builtin_popcount(i);
                
                for(int a=0;a<5;a++){
                    if(dp[j][i][a]==false) continue;
                    
                    for(int x=0;x<K;x++){
                        if(i&(1<<x)) continue;
                        
                        int to=a+S[x][j];if(to>=5) to-=5;
                        
                        dp[j+1][i|(1<<x)][to]=true;
                    }
                    
                    if(K+s<si(S)){
                        int to=a+S[K+s][j];if(to>=5) to-=5;
                        
                        dp[j+1][i][to]=true;
                    }else if(K+s-si(S)<si(T)){
                        int to=a+T[K+s-si(S)][j];if(to>=5) to-=5;
                        
                        dp[j+1][i][to]=true;
                    }
                }
            }
        }
        
        for(int a=0;a<5;a++){
            if(dp[N][(1<<K)-1][a]) ans[a]=true;
        }
        
        if(ans[0]&&ans[1]&&ans[2]&&ans[3]&&ans[4]) break;
    }
    
    for(int i=0;i<5;i++){
        if(ans[i]) cout<<"Y";
        else cout<<"N";
    }
    cout<<endl;
}


详细

Test #1:

score: 100
Accepted
time: 603ms
memory: 8600kb

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

score: 0
Accepted
time: 594ms
memory: 8556kb

input:

2
1 1
1 1

output:

NNYNN

result:

ok "NNYNN"

Test #3:

score: 0
Accepted
time: 603ms
memory: 8516kb

input:

4
0 0 1 0
0 1 0 1
0 0 0 0
1 1 0 0

output:

YYYYN

result:

ok "YYYYN"

Test #4:

score: 0
Accepted
time: 598ms
memory: 8572kb

input:

4
0 0 0 1
0 1 0 1
1 0 0 0
0 1 0 0

output:

YYYYN

result:

ok "YYYYN"

Test #5:

score: 0
Accepted
time: 594ms
memory: 8640kb

input:

10
1 4 2 0 0 2 0 1 3 3
0 3 1 4 4 1 4 0 2 2
1 4 2 0 0 2 0 1 0 3
0 3 1 4 4 1 4 0 2 2
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
1 4 2 0 0 2 0 1 3 3
3 1 4 2 2 4 2 3 0 0

output:

NYNNY

result:

ok "NYNNY"

Test #6:

score: 0
Accepted
time: 598ms
memory: 8624kb

input:

10
4 4 4 1 3 4 1 4 3 0
3 3 3 0 2 3 0 3 2 4
3 3 3 0 2 3 0 3 2 4
4 4 4 1 3 4 1 4 3 0
2 2 2 4 1 2 4 2 1 3
2 2 2 4 1 3 4 2 1 3
4 4 4 1 3 4 1 4 3 0
3 3 3 0 2 3 0 3 2 4
2 2 2 4 1 2 4 2 1 3
4 4 4 1 3 4 1 1 3 0

output:

YYYNY

result:

ok "YYYNY"

Test #7:

score: 0
Accepted
time: 605ms
memory: 8484kb

input:

10
1 2 0 4 2 3 4 0 2 3
0 1 4 3 1 2 3 4 1 2
4 0 3 2 0 1 2 3 0 1
1 2 0 4 2 3 4 0 2 3
3 4 2 1 4 0 1 2 4 0
0 1 4 3 1 2 3 4 1 2
2 3 1 0 3 4 0 1 3 4
3 1 1 1 4 0 1 2 4 0
1 2 0 4 2 3 4 0 2 3
1 3 0 4 2 3 4 0 2 3

output:

NYYYY

result:

ok "NYYYY"

Test #8:

score: 0
Accepted
time: 603ms
memory: 8748kb

input:

10
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4
2 3 4 2 1 1 4 3 4 1
0 1 2 0 4 4 2 1 2 4
0 1 2 0 4 4 2 1 2 4
0 1 2 0 4 4 2 1 2 4
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4

output:

NYNNN

result:

ok "NYNNN"

Test #9:

score: 0
Accepted
time: 2ms
memory: 8516kb

input:

10
4 1 3 1 2 0 3 2 4 4
0 2 4 2 3 1 4 3 0 0
1 1 1 1 2 0 3 2 4 1
2 4 1 4 0 3 1 0 2 2
1 3 0 3 4 2 0 4 1 1
2 4 1 4 0 3 1 0 2 2
2 4 1 4 0 3 1 0 2 2
0 2 4 2 3 1 4 3 0 0
3 0 2 1 1 4 2 1 3 3
4 1 3 1 2 0 3 2 4 4

output:

YYYYY

result:

ok "YYYYY"

Test #10:

score: 0
Accepted
time: 593ms
memory: 8604kb

input:

10
1 2 0 2 4 2 3 1 2 1
4 0 3 0 2 0 1 4 0 4
0 1 4 1 3 1 2 0 1 0
0 1 4 1 3 1 2 0 1 0
3 4 2 4 1 4 0 3 4 3
4 0 3 0 2 0 1 4 0 4
0 1 4 1 3 1 2 0 1 0
0 1 4 1 3 1 2 0 1 0
3 4 2 4 1 4 0 3 4 3
0 1 4 1 3 1 2 0 1 0

output:

NNNYN

result:

ok "NNNYN"

Test #11:

score: 0
Accepted
time: 0ms
memory: 8556kb

input:

10
1 4 1 2 1 3 3 2 1 2
0 3 0 1 0 2 2 1 0 1
0 4 0 3 0 2 2 1 0 1
1 4 1 2 1 3 3 2 1 2
4 2 4 0 4 1 1 0 4 0
1 1 1 4 1 0 3 2 1 2
0 0 0 1 0 2 2 1 0 1
2 0 2 3 2 4 4 3 2 3
2 0 2 3 2 4 4 3 2 3
2 0 2 3 2 4 4 3 2 3

output:

YYYYY

result:

ok "YYYYY"

Test #12:

score: 0
Accepted
time: 604ms
memory: 8748kb

input:

10
1 2 0 1 4 0 1 2 2 2
1 2 0 1 4 3 1 2 2 2
0 1 4 0 3 1 0 1 1 1
1 2 0 1 4 3 1 2 2 2
3 4 2 3 1 4 3 4 4 4
0 1 4 0 3 1 0 1 1 1
4 0 3 4 2 0 4 0 0 0
3 4 2 3 1 4 3 4 4 4
4 0 3 4 2 0 4 0 0 0
0 1 4 0 3 1 0 1 1 1

output:

YNYNY

result:

ok "YNYNY"

Test #13:

score: -100
Wrong Answer
time: 0ms
memory: 8616kb

input:

10
1 3 0 0 2 1 3 4 3 3
3 3 0 0 4 1 3 4 3 3
1 1 3 3 2 4 1 2 1 1
2 4 1 1 3 2 4 0 4 4
4 1 3 3 0 4 1 2 1 1
2 4 1 1 3 2 4 0 4 4
0 2 4 4 1 0 2 3 2 2
3 0 2 2 4 3 0 1 0 0
3 0 2 2 4 3 0 1 0 0
4 2 4 4 1 0 2 3 2 2

output:

YYYYY

result:

wrong answer 1st words differ - expected: 'YYYNY', found: 'YYYYY'