QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#19433#1805. Bunch of PaperYaoBIG#WA 3ms3820kbC++172.1kb2022-01-31 01:09:052022-05-06 05:21:04

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 05:21:04]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3820kb
  • [2022-01-31 01:09:05]
  • 提交

answer

#include "bits/stdc++.h"
#define rep(i,a,n) for(auto i=a;i<=n;i++)
#define per(i,a,n) for(auto i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define all(A) A.begin(),A.end()
#define sz(A) (int)A.size()
template<class T> bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
using namespace std;

string to_string(const string& s) {return '"' + s + '"';}
string to_string(const char* s) {return to_string((string) s);}
template<typename A, typename B> string to_string(pair<A, B> p) {return "(" + to_string(p.FI) + ", " + to_string(p.SE) + ")";}
template<typename A> string to_string(A v) 
{
    bool first = 1;
    string res = "{";
    for(const auto &x: v) 
    {
        if (!first) res += ", ";
        first = 0;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() {cerr << endl;} 
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) 
{
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifndef ONLINE_JUDGE
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) if(0) puts("No effect.")
#endif

using ll = long long;
//using LL = __int128;
using pii = pair<int,int>;
using vi = vector<int>;
using db = double;
using ldb = long double;

const int maxn = 10000;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;

inline void chsub(int &x,const int &y) {x-=y; if(x<0) x+=mod;}
inline void chadd(int &x,const int &y) {x+=y; if(x>=mod) x-=mod;}

int a[2][maxn+5],dp[2][maxn+5];

int main()
{
    int n,k; scanf("%d%d",&n,&k);
    int cur = 0;
    dp[cur][1] = 1;
    rep(_,1,n) 
    {
        int old = cur; cur ^= 1;
        rep(i,1,k) scanf("%d",&a[cur][i]);
        int sum = 0, ptr = 0;
        rep(i,1,k)
        {
            while(ptr+1<=k && a[old][ptr+1]<=a[cur][i]) chadd(sum,dp[old][++ptr]);
            dp[cur][i] = sum;
        }
    }
    int ans = 0;
    rep(i,1,k) chadd(ans,dp[cur][i]);
    printf("%d\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3716kb

input:

2 2
2 4
1 5

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

2 3
4 5 6
1 2 3

output:

0

result:

ok answer is '0'

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3812kb

input:

20 20
2 8 12 17 19 29 41 53 57 62 63 65 67 70 71 74 76 77 96 100
2 3 9 13 15 16 20 26 28 33 38 39 46 51 58 59 74 92 93 99
2 5 6 9 19 20 22 24 26 35 41 45 56 60 62 74 76 81 83 96
3 7 10 11 13 15 17 20 22 26 34 35 43 59 68 78 82 83 85 93
1 7 11 14 17 26 37 41 45 49 62 63 64 67 71 74 88 89 91 94
12 15 ...

output:

195949598

result:

wrong answer expected '188926982', found '195949598'