QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#37758 | #1261. Inv | zshccc | TL | 3ms | 7664kb | C++ | 779b | 2022-07-02 20:46:49 | 2022-07-02 20:46:52 |
Judging History
answer
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define pb push_back
#define SZ(a) ((int)(a.size()))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
using namespace std;
const int N=510;
// dp[i][j] //前i个数,逆序数为j
//
//
//
int dp[N][N*N/2];
signed main(){
int n,k;
cin>>n>>k;
dp[0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=k;j++){
for(int t=0;t<=i-1&&t<=j;t++){
// dp[i+1][j+t]+=dp[i][j];
dp[i][j]+=dp[i-1][j-t]; //可以用前缀和优化
// or dp[i][j]= sigma(dp[i-1][j-1],dp[i-1][j-2]......)
}
}
}
cout<<dp[n][k]%2<<endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 5656kb
input:
4 1
output:
1
result:
ok answer is '1'
Test #2:
score: 0
Accepted
time: 3ms
memory: 7664kb
input:
10 21
output:
0
result:
ok answer is '0'
Test #3:
score: -100
Time Limit Exceeded
input:
500 124331