Submission #292999

# Submission time Handle Problem Language Result Execution time Memory
292999 2020-09-07T15:26:10 Z 최은수(#5797) Robogolf (ROI19_golf) C++17
14 / 100
74 ms 13164 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
const int mod=998244353;
inline int add(int x,int y)
{
    return x+y<mod?x+y:x+y-mod;
}
inline int sub(int x,int y)
{
    return x<y?x+mod-y:x-y;
}
inline int mul(int x,int y)
{
    return(int)((ll)x*y%mod);
}
int val[7][1000010];
bool chk[7][1000010];
int dp1[7][1000010],dp2[7][1000010];
int ans;
int n,m;
inline void process(vector<pair<pi,int> >&v)
{
    int dif=max(0,v[0].fi.se-7);
    for(auto&t:v)
        t.fi.se-=dif;
    int m2=v.back().fi.se;
    for(auto&t:v)
        chk[t.fi.fi][t.fi.se]=1,val[t.fi.fi][t.fi.se]=t.se;
    for(int i=n;i>0;i--)
    {
        for(int j=m2;j>0;j--)
        {
            if(chk[i][j])
                dp1[i][j]=dp2[i][j]=val[i][j];
            else
                dp1[i][j]=min(dp2[i+1][j],dp2[i][j+1]),
                dp2[i][j]=max(dp1[i+1][j],dp1[i][j+1]);
            ans=add(ans,(dp1[i][j]%mod+mod)%mod);
        }
    }
    for(int i=n;i>0;i--)
        for(int j=m2;j>0;j--)
            dp1[i][j]=dp2[i][j]=val[i][j]=0,chk[i][j]=0;
    v.clear();
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin>>n>>m>>k;
    vector<pair<pi,int> >v(k);
    for(auto&t:v)
        cin>>t.fi.fi>>t.fi.se>>t.se;
    sort(all(v),[](const pair<pi,int>&x,const pair<pi,int>&y){return x.fi.se<y.fi.se;});
    vector<pair<pi,int> >v2;
    for(auto&t:v)
    {
        if(!v2.empty()&&v2.back().fi.se+7<t.fi.se)
            process(v2);
        v2.eb(t);
    }
    process(v2);
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 0 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Runtime error 6 ms 512 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 9 ms 1788 KB Output is correct
4 Correct 44 ms 2872 KB Output is correct
5 Correct 62 ms 1708 KB Output is correct
6 Correct 69 ms 1656 KB Output is correct
7 Correct 74 ms 1784 KB Output is correct
8 Correct 48 ms 1536 KB Output is correct
9 Correct 52 ms 1536 KB Output is correct
10 Correct 59 ms 1656 KB Output is correct
11 Correct 65 ms 1656 KB Output is correct
12 Correct 72 ms 1656 KB Output is correct
13 Correct 72 ms 1656 KB Output is correct
14 Correct 72 ms 1656 KB Output is correct
15 Correct 55 ms 1656 KB Output is correct
16 Correct 51 ms 1656 KB Output is correct
17 Correct 67 ms 1656 KB Output is correct
18 Correct 49 ms 1656 KB Output is correct
19 Correct 48 ms 1656 KB Output is correct
20 Correct 49 ms 1656 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 47 ms 8684 KB Output is correct
27 Correct 48 ms 13164 KB Output is correct
28 Correct 31 ms 5868 KB Output is correct
29 Correct 31 ms 5612 KB Output is correct
30 Correct 34 ms 5364 KB Output is correct
31 Correct 35 ms 6508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 4076 KB Output is correct
2 Runtime error 43 ms 5484 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 0 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Runtime error 6 ms 512 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 3192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 3192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 0 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Runtime error 6 ms 512 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 0 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Runtime error 6 ms 512 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -