답안 #994853

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994853 2024-06-08T07:38:54 Z guagua0407 Bowling (BOI15_bow) C++17
26 / 100
4 ms 348 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

void solve(){
    int n;
    cin>>n;
    vector<string> str(n);
    for(int i=0;i<n;i++){
        char a,b,c;
        cin>>a>>b;
        if(i==n-1) cin>>c;
        string A(1,a);
        string B(1,b);
        string C(1,c);
        str[i]=A+B;
        //if(i==n-1) str[i]+=C;
    }
    vector<int> val(n);
    for(int i=0;i<n;i++){
        cin>>val[i];
    }
    vector<string> cand;
    for(int i=0;i<10;i++){
        for(int j=0;j+i<10;j++){
            string A(1,(char)('0'+i));
            string B(1,(char)('0'+j));
            string tmp=A+B;
            //cout<<tmp<<'\n';
            cand.push_back(tmp);
        }
        //string tmp={(char)(i-'0'),'/'};
        //cand.push_back(tmp);
    }
    vector<ll> dp(305);
    dp[0]=1;
    for(int i=0;i<n;i++){
        vector<ll> ndp(305);
        for(auto cur:cand){
            bool tf=true;
            for(int j=0;j<2;j++){
                if(str[i][j]!='?' and str[i][j]!=cur[j]){
                    tf=false;
                }
            }
            if(!tf) continue;
            //cout<<cur<<'\n';
            int st,en;
            if(cur[0]=='x') st=10;
            else st=(int)(cur[0]-'0');
            if(cur[1]=='-') en=-1;
            else if(cur[1]=='/') en=10-st;
            else en=(int)(cur[1]-'0');
            for(int j=0;j+st+en<305;j++){
                ndp[j+st+en]+=dp[j];
            }
        }
        swap(dp,ndp);
        if(val[i]!=-1){
            for(int j=0;j<305;j++){
                if(j!=val[i]){
                    dp[j]=0;
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<305;i++){
        ans+=dp[i];
    }
    cout<<ans<<'\n';
}

int main() {_
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
//maybe its multiset not set
//yeeorz
//laborz

Compilation message

bow.cpp: In function 'void setIO(std::string)':
bow.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bow.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -