Submission #292997

# Submission time Handle Problem Language Result Execution time Memory
292997 2020-09-07T15:25:09 Z 최은수(#5797) Robogolf (ROI19_golf) C++17
0 / 100
43 ms 5612 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-5);
    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 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 0 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 416 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 9 ms 1788 KB Output is correct
4 Incorrect 43 ms 2872 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 4076 KB Output is correct
2 Runtime error 41 ms 5612 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 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 0 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 40 ms 3372 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 40 ms 3372 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 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 0 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 7 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 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 0 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 -