ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#200 | #6. 「WyOJ Round 1」持 · 山海为肩 | __vector__ | 20 | 6313ms | 233664kb | C++23 | 4.8kb | 2025-04-18 08:09:20 | 2025-04-18 13:17:48 |
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(auto i=(a);i<=(b);i++)
#define REP(i,a,b) for(auto i=(a);i>=(b);i--)
#define FORK(i,a,b,k) for(auto i=(a);i<=(b);i+=(k))
#define REPK(i,a,b,k) for(auto i=(a);i>=(b);i-=(k))
#define pb push_back
#define mkpr make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
template<class T>
void ckmx(T& a,T b){
a=max(a,b);
}
template<class T>
void ckmn(T& a,T b){
a=min(a,b);
}
template<class T>
T gcd(T a,T b){
return !b?a:gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
return a/gcd(a,b)*b;
}
#define gc getchar()
#define eb emplace_back
#define pc putchar
#define ep empty()
#define fi first
#define se second
#define pln pc('\n');
#define islower(ch) (ch>='a'&&ch<='z')
#define isupper(ch) (ch>='A'&&ch<='Z')
#define isalpha(ch) (islower(ch)||isupper(ch))
template<class T>
void wrint(T x){
if(x<0){
x=-x;
pc('-');
}
if(x>=10){
wrint(x/10);
}
pc(x%10^48);
}
template<class T>
void wrintln(T x){
wrint(x);
pln
}
template<class T>
void read(T& x){
x=0;
int f=1;
char ch=gc;
while(!isdigit(ch)){
if(ch=='-')f=-1;
ch=gc;
}
while(isdigit(ch)){
x=(x<<1)+(x<<3)+(ch^48);
ch=gc;
}
x*=f;
}
void io(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const int maxn=1e5+5;
int n,m;
double p[maxn];
int seq[maxn][13];
double dp[531441+5][2][27];
const int add=13;
int pw3[13];
void solve(int id_of_test){
cin>>n>>m;
FOR(i,1,n){
cin>>p[i];
FOR(j,1,m){
string s;
cin>>s;
if(s=="rock")seq[i][j]=0;
if(s=="scissors")seq[i][j]=1;
if(s=="paper")seq[i][j]=2;
}
}
int all=0;
all=pw3[m]-1;
// printf("all = %d\n",all);
FOR(i,1,n){
int b=0;
FOR(j,1,m){
b+=pw3[j-1]*seq[i][j];
}
// printf("b = %d\n",b);
dp[b][0][add]+=p[i];
}
/*FOR(s,0,all){
FOR(add,0,25){
printf("dp[%d][%d][%d] = %.5lf\n",s,0,add,dp[s][0][add]);
}
}*/
// return;
FOR(i,1,m){
bool cur=i&1;
FOR(s,0,all){
FOR(win,0,25){
dp[s][cur][win]=dp[s][cur^1][win];
if(win){
int nw=(s/pw3[i-1])%3;
int old=(nw+1)%3;
// printf("s = %d i %d win = %d from %d %d\n",s,i,win,s-pw3[i-1]*nw+pw3[i-1]*old,win-1);
dp[s][cur][win]+=dp[s-pw3[i-1]*nw+pw3[i-1]*old][cur^1][win-1];
// printf("dp[s=%d][i=%d][win=%d] = %.5lf\n",s,i,win,dp[s][i][win]);
}
if(win<26){
int nw=(s/pw3[i-1])%3;
int old=(nw-1)%3;
old=(old+3)%3;
dp[s][cur][win]+=dp[s-pw3[i-1]*nw+pw3[i-1]*old][cur^1][win+1];
}
/* if(dp[s][i][win]){
printf("%d %d %d %.5lf\n",s,i,win,dp[s][i][win]);
}*/
}
}
}
double mxans=0;
FOR(s,0,all){
double nwans=0;
FOR(win,add,25){
nwans+=dp[s][m&1][win];
}
ckmx(mxans,nwans);
}
printf("%.6lf\n",mxans);
vi ans;
FOR(s,0,all){
int olds=s;
double nwans=0;
FOR(win,add,25){
nwans+=dp[s][m&1][win];
}
if(nwans==mxans){
// printf("nw = %d\n",s);
vi nw;
while(s){
nw.eb(s%3);
s/=3;
}
while(nw.size()<m)nw.eb(0);
// reverse(nw.begin(),nw.end());
if(ans.empty())ans=nw;
else{
bool less=1;
for(int i=0;i<m;i++){
int va,vb;
if(nw[i]==0)va=0;
else if(nw[i]==1)va=2;
else va=1;
if(ans[i]==0)vb=0;
else if(ans[i]==1)vb=2;
else vb=1;
if(va<vb){
break;
}else if(va==vb){
continue;
}else{
less=0;
break;
}
}
if(less){
ans=nw;
}
}
}
s=olds;
}
for(int& v:ans){
if(v==0)cout<<"rock ";
else if(v==1)cout<<"scissors ";
else cout<<"paper ";
}
cout<<'\n';
}
int main()
{
// io();
pw3[0]=1;
FOR(i,1,12)pw3[i]=pw3[i-1]*3;
int T;
T=1;
FOR(_,1,T){
solve(_);
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 9ms
memory: 5720kb
input:
841 5 0.002262 paper rock rock scissors scissors 0.000665 rock paper paper scissors paper 0.001132 s...
output:
0.689135
result:
wrong answer Unexpected EOF in the participants output
Test #2:
score: 10
Accepted
time: 4ms
memory: 7568kb
input:
320 1 0.001734 rock 0.000432 rock 0.003306 scissors 0.000322 paper 0.000380 rock 0.000817 scissors 0...
output:
0.728099 rock
result:
ok 2 tokens
Test #3:
score: 10
Accepted
time: 0ms
memory: 5676kb
input:
19 2 0.086520 scissors rock 0.028985 rock rock 0.056406 rock scissors 0.010732 scissors rock 0.04471...
output:
0.836348 scissors rock
result:
ok 3 tokens
Test #4:
score: 0
Wrong Answer
time: 1241ms
memory: 233664kb
input:
100000 12 0.000008 rock rock rock scissors paper scissors paper paper paper scissors paper scissors ...
output:
0.578764
result:
wrong answer Unexpected EOF in the participants output
Test #5:
score: 0
Wrong Answer
time: 615ms
memory: 85036kb
input:
82918 11 0.000009 paper rock rock scissors scissors paper rock paper rock rock paper 0.000000 scisso...
output:
0.582727
result:
wrong answer Unexpected EOF in the participants output
Test #6:
score: 0
Wrong Answer
time: 381ms
memory: 34976kb
input:
63157 10 0.000004 rock scissors paper scissors paper scissors rock paper rock scissors 0.000007 rock...
output:
0.587712
result:
wrong answer Unexpected EOF in the participants output
Test #7:
score: 0
Wrong Answer
time: 1258ms
memory: 233608kb
input:
100000 12 0.000003 rock rock rock paper paper rock paper paper paper rock rock scissors 0.000001 pap...
output:
0.578665
result:
wrong answer Unexpected EOF in the participants output
Test #8:
score: 0
Wrong Answer
time: 589ms
memory: 84880kb
input:
72055 11 0.000006 rock scissors scissors rock scissors scissors scissors scissors rock scissors scis...
output:
0.584229
result:
wrong answer Unexpected EOF in the participants output
Test #9:
score: 0
Wrong Answer
time: 962ms
memory: 232244kb
input:
49463 12 0.000024 rock paper scissors paper rock scissors rock paper paper paper paper paper 0.00000...
output:
0.584658
result:
wrong answer Unexpected EOF in the participants output
Test #10:
score: 0
Wrong Answer
time: 1254ms
memory: 233564kb
input:
100000 12 0.000007 rock paper scissors paper paper scissors rock rock scissors rock scissors paper 0...
output:
0.578092
result:
wrong answer Unexpected EOF in the participants output