Submission #994850

#TimeUsernameProblemLanguageResultExecution timeMemory
994850guagua0407Bowling (BOI15_bow)C++17
0 / 100
0 ms348 KiB
//#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 tmp={(char)(i-'0'),(char)(j-'0')}; cand.push_back(tmp); } //string tmp={(char)(i-'0'),'/'}; //cand.push_back(tmp); } //cand.push_back("x-"); return ; 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; 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+en+st<305;j++){ ndp[j+st+en]+=dp[j]; } } 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 (stderr)

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);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...