QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#37758#1261. InvzshcccTL 3ms7664kbC++779b2022-07-02 20:46:492022-07-02 20:46:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-02 20:46:52]
  • 评测
  • 测评结果:TL
  • 用时:3ms
  • 内存:7664kb
  • [2022-07-02 20:46:49]
  • 提交

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;

}

Details

Tip: Click on the bar to expand more detailed information

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

output:


result: