QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488284#7301. Even Three is OddxlwangWA 1ms3756kbC++142.4kb2024-07-23 19:59:062024-07-23 19:59:06

Judging History

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

  • [2024-07-23 19:59:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3756kb
  • [2024-07-23 19:59:06]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
#define pii pair<int,int>
#define mk make_pair
using namespace std;
inline int read(){
	int x=0;
	bool f=0;
	char c=getchar();
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
inline void write(int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
const int Maxn=2e3+10,mod=1e9+7;
int n,val[Maxn];
inline void add(int &x,int y){x+=y;if(x>=mod) x-=mod;}
int f[Maxn][Maxn][2];
int S[Maxn];
inline void work(){
    fr(i,1,n) val[i]=read();
	fr(i,0,n) fr(j,0,n) fr(k,0,1) f[i][j][k]=0;
	fr(i,1,n){
		f[2][i][0]=1;f[2][i][1]=i-1;
	}
	fr(i,3,n){
		fr(j,1,n) S[j]=(S[j-1]+f[i-1][j][1])%mod;
		fr(k,1,n) add(f[i][k][1],1ll*S[k-1]*val[k]%mod);
		fr(j,1,n) S[j]=(S[j-1]+1ll*f[i-1][j][0]*j%mod)%mod;
		fr(k,1,n) add(f[i][k][1],1ll*S[k]*val[k]%mod);
		S[n+1]=0;rf(j,n,1) S[j]=(S[j+1]+1ll*f[i-1][j][0]*val[j]%mod)%mod;
		fr(k,1,n) add(f[i][k][1],1ll*S[k]*(k-1)%mod);
		S[n+1]=0;rf(j,n,1) S[j]=(S[j+1]+1ll*f[i-1][j][0]*val[j]%mod)%mod;
		fr(k,1,n) add(f[i][k][0],S[k+1]);
		fr(k,1,n) add(f[i][k][0],1ll*f[i-1][k][1]*val[k]%mod);
		// fr(j,1,n){
			// fr(k,j+1,n) add(f[i][k][1],1ll*f[i-1][j][1]*val[k]%mod);
			// add(f[i][j][0],1ll*f[i-1][j][1]*val[j]%mod);
			// fr(k,j,n) add(f[i][k][1],1ll*f[i-1][j][0]*j%mod*val[k]%mod);
			// fr(k,1,j) add(f[i][k][1],1ll*f[i-1][j][0]*val[j]%mod*(k-1)%mod);
			// fr(k,1,j-1) add(f[i][k][0],1ll*f[i-1][j][0]*val[j]%mod);
		// }
	}
	// fr(i,1,n) fr(j,1,n) fr(k,0,1) cout<<i<<' '<<j<<' '<<k<<' '<<f[i][j][k]<<endl;
	int ans=0;
	fr(i,1,n){
		add(ans,f[n][i][1]);
		add(ans,1ll*f[n][i][0]*i%mod);
	}
	writeln(ans);
}
inline void init(){
    while(cin>>n) work();
}
signed main(){
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	init();
    // printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

input:

3
1 2 3
4
1 1 1 1

output:

72
256

result:

ok 2 number(s): "72 256"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3756kb

input:

20
2 1 1 2 1 1 2 2 1 1 1 2 1 2 2 2 2 2 1 1
20
1 1 1 1 1 1 1 2 2 2 2 1 2 1 2 1 1 1 2 2
20
2 1 2 2 1 2 2 1 1 1 2 1 2 1 2 2 1 1 2 1
20
1 1 1 1 1 2 1 1 1 2 1 2 2 1 1 2 2 2 1 2
20
2 2 1 1 2 2 2 1 2 2 1 2 2 2 2 1 2 2 2 2
20
1 1 2 1 2 1 2 2 1 2 2 2 1 2 1 2 2 2 1 1
20
1 2 1 1 1 2 1 1 1 1 1 2 1 2 1 1 2 2 2 1...

output:

81984004
691513617
810379490
626583643
760539454
338523770
159908083
986361466
266812968
477162771
860400618
203389561
426575296
415426803
116151971
491886801
139938615
23743767
712091065
875095490
508797804
604889604
712355653
638222979
497367851
838220726
590117935
62369528
94194919
715172062
6157...

result:

wrong answer 1st numbers differ - expected: '319733964', found: '81984004'