QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#459414#8830. Breaking Baducup-team1134#WA 600ms8740kbC++232.9kb2024-06-30 03:28:462024-06-30 03:28:46

Judging History

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

  • [2024-06-30 03:28:46]
  • 评测
  • 测评结果:WA
  • 用时:600ms
  • 内存:8740kb
  • [2024-06-30 03:28:46]
  • 提交

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++){
            A[j]=rng()%5;
        }
        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;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 600ms
memory: 8740kb

input:

2
0 4
4 0

output:

NNNYN

result:

wrong answer 1st words differ - expected: 'YNNYN', found: 'NNNYN'