Submission #879583

# Submission time Handle Problem Language Result Execution time Memory
879583 2023-11-27T16:36:06 Z Rafi22 World of Tank (innopolis2018_final_E) C++14
50 / 100
646 ms 99288 KB
#include <bits/stdc++.h>

//#define int long long
#define ll long long
#define ld long double
//#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
ll infl=1000000000000000007;
int inf=2000000007;
int mod=1000000007;
int mod1=998244353;

const int N=1000007;

int a[N][2];
map<int,int>M;

int DP[2*N][2];
int zkad[2*N][2];
bool blocked[2*N][2];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    set<int>S;
    int n,m1,m2,t;
    cin>>n>>m1>>m2>>t;
    S.insert(0);
    S.insert(n+1);
    for(int i=1;i<=m1;i++)
    {
        cin>>a[i][0];
        S.insert(a[i][0]);
        S.insert(a[i][0]-1);
    }
    for(int i=1;i<=m2;i++)
    {
        cin>>a[i][1];
        S.insert(a[i][1]);
        S.insert(a[i][1]-1);
    }
    int k=0;
    vector<int>d={213769420};
    for(auto x:S)
    {
        M[x]=++k;
        d.pb(x);
    }
    for(int i=1;i<=m1;i++) blocked[M[a[i][0]]][0]=1;
    for(int i=1;i<=m2;i++) blocked[M[a[i][1]]][1]=1;
    for(int j=0;j<2;j++) for(int i=1;i<=k;i++) DP[i][j]=-inf;
    DP[1][0]=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<2;j++)
        {
            if(!blocked[i][j^1]&&min(t,DP[i][j])>DP[i][j^1])
            {
                DP[i][j^1]=min(t,DP[i][j]);
                zkad[i][j^1]=2;
            }
        }
        for(int j=0;j<2;j++)
        {
            if(blocked[i+1][j])
            {
                if(DP[i][j]>=t&&DP[i][j]+1-t>DP[i+1][j])
                {
                    DP[i+1][j]=DP[i][j]+1-t;
                    zkad[i+1][j]=3;
                }
            }
            else if(DP[i][j]+d[i+1]-d[i]>DP[i+1][j])
            {
                DP[i+1][j]=DP[i][j]+d[i+1]-d[i];
                zkad[i+1][j]=1;
            }
        }
    }
    if(DP[k][0]>=0)
    {
        cout<<"Yes"<<endl;
        int i=k,j=0;
        vector<int>X;
        vector<pair<int,int>>Y;
        while(zkad[i][j]!=0)
        {
            if(zkad[i][j]==1) i--;
            else if(zkad[i][j]==2)
            {
                X.pb(d[i]);
                j^=1;
            }
            else
            {
                Y.pb({d[i]-DP[i][j],j+1});
                i--;
            }
        }
        reverse(all(X));
        reverse(all(Y));
        cout<<sz(X)<<endl;
        for(auto x:X) cout<<x<<" ";
        cout<<endl;
        cout<<sz(Y)<<endl;
        for(auto [x,y]:Y) cout<<x<<" "<<y<<endl;
    }
    else cout<<"No"<<endl;
}

Compilation message

E.cpp: In function 'int main()':
E.cpp:113:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  113 |         for(auto [x,y]:Y) cout<<x<<" "<<y<<endl;
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20
2 Correct 1 ms 6748 KB [OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000
3 Correct 1 ms 6748 KB [OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000
4 Correct 2 ms 6744 KB [OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000
5 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000
6 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000
7 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000
8 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000
9 Correct 2 ms 6752 KB [OK, No] n = 5000, m1 = 1006, m2 = 995, t = 5000
10 Correct 2 ms 6748 KB [OK, No] n = 5000, m1 = 1017, m2 = 984, t = 5000
11 Correct 2 ms 6884 KB [OK, No] n = 5000, m1 = 1495, m2 = 1506, t = 5000
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20
2 Correct 1 ms 6748 KB [OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000
3 Correct 1 ms 6748 KB [OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000
4 Correct 2 ms 6744 KB [OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000
5 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000
6 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000
7 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000
8 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000
9 Correct 2 ms 6752 KB [OK, No] n = 5000, m1 = 1006, m2 = 995, t = 5000
10 Correct 2 ms 6748 KB [OK, No] n = 5000, m1 = 1017, m2 = 984, t = 5000
11 Correct 2 ms 6884 KB [OK, No] n = 5000, m1 = 1495, m2 = 1506, t = 5000
12 Correct 2 ms 6876 KB [OK, Yes] n = 5000, m1 = 974, m2 = 1026, t = 2501
13 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 1022, m2 = 978, t = 2501
14 Correct 2 ms 6892 KB [OK, Yes] n = 5000, m1 = 1019, m2 = 981, t = 2501
15 Correct 2 ms 7004 KB [OK, Yes] n = 5000, m1 = 1298, m2 = 1367, t = 2501
16 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1301, m2 = 1360, t = 2501
17 Correct 2 ms 7004 KB [OK, Yes] n = 5000, m1 = 1320, m2 = 1315, t = 2501
18 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1195, m2 = 1135, t = 2501
19 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1148, m2 = 1202, t = 2501
20 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1147, m2 = 1179, t = 2501
21 Correct 2 ms 7008 KB [OK, No] n = 5000, m1 = 1163, m2 = 1146, t = 2501
22 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1145, m2 = 1184, t = 2501
23 Correct 2 ms 6872 KB [OK, No] n = 5000, m1 = 1172, m2 = 1150, t = 2501
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 12, m2 = 9, t = 3
2 Correct 1 ms 6492 KB [OK, Yes] n = 10, m1 = 4, m2 = 2, t = 2
3 Correct 1 ms 6612 KB [OK, Yes] n = 10, m1 = 6, m2 = 0, t = 2
4 Correct 1 ms 6492 KB [OK, Yes] n = 10, m1 = 2, m2 = 4, t = 1
5 Correct 1 ms 6504 KB [OK, No] n = 20, m1 = 4, m2 = 11, t = 2
6 Correct 1 ms 6500 KB [OK, Yes] n = 20, m1 = 7, m2 = 8, t = 1
7 Correct 2 ms 6504 KB [OK, Yes] n = 20, m1 = 7, m2 = 8, t = 2
8 Correct 1 ms 6628 KB [OK, Yes] n = 20, m1 = 0, m2 = 10, t = 2
9 Correct 1 ms 6500 KB [OK, Yes] n = 20, m1 = 4, m2 = 6, t = 2
10 Correct 1 ms 6500 KB [OK, Yes] n = 20, m1 = 9, m2 = 1, t = 2
11 Correct 1 ms 6504 KB [OK, Yes] n = 20, m1 = 10, m2 = 9, t = 2
12 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 9, m2 = 10, t = 2
13 Correct 1 ms 6616 KB [OK, Yes] n = 20, m1 = 0, m2 = 0, t = 3
14 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 5, m2 = 4, t = 3
15 Correct 1 ms 6492 KB [OK, Yes] n = 9, m1 = 4, m2 = 3, t = 3
16 Correct 1 ms 6612 KB [OK, Yes] n = 20, m1 = 8, m2 = 8, t = 3
17 Correct 1 ms 6620 KB [OK, Yes] n = 20, m1 = 9, m2 = 7, t = 3
18 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 9, m2 = 10, t = 7
19 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 7, m2 = 10, t = 8
20 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 13, m2 = 10, t = 4
21 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 9, m2 = 9, t = 8
22 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 10, m2 = 11, t = 3
23 Correct 1 ms 6624 KB [OK, Yes] n = 20, m1 = 11, m2 = 11, t = 3
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20
2 Correct 1 ms 6748 KB [OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000
3 Correct 1 ms 6748 KB [OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000
4 Correct 2 ms 6744 KB [OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000
5 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000
6 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000
7 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000
8 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000
9 Correct 2 ms 6752 KB [OK, No] n = 5000, m1 = 1006, m2 = 995, t = 5000
10 Correct 2 ms 6748 KB [OK, No] n = 5000, m1 = 1017, m2 = 984, t = 5000
11 Correct 2 ms 6884 KB [OK, No] n = 5000, m1 = 1495, m2 = 1506, t = 5000
12 Correct 2 ms 6876 KB [OK, Yes] n = 5000, m1 = 974, m2 = 1026, t = 2501
13 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 1022, m2 = 978, t = 2501
14 Correct 2 ms 6892 KB [OK, Yes] n = 5000, m1 = 1019, m2 = 981, t = 2501
15 Correct 2 ms 7004 KB [OK, Yes] n = 5000, m1 = 1298, m2 = 1367, t = 2501
16 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1301, m2 = 1360, t = 2501
17 Correct 2 ms 7004 KB [OK, Yes] n = 5000, m1 = 1320, m2 = 1315, t = 2501
18 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1195, m2 = 1135, t = 2501
19 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1148, m2 = 1202, t = 2501
20 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1147, m2 = 1179, t = 2501
21 Correct 2 ms 7008 KB [OK, No] n = 5000, m1 = 1163, m2 = 1146, t = 2501
22 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1145, m2 = 1184, t = 2501
23 Correct 2 ms 6872 KB [OK, No] n = 5000, m1 = 1172, m2 = 1150, t = 2501
24 Correct 1 ms 6492 KB [OK, Yes] n = 500, m1 = 197, m2 = 53, t = 2
25 Correct 1 ms 6492 KB [OK, Yes] n = 500, m1 = 189, m2 = 61, t = 3
26 Correct 1 ms 6492 KB [OK, No] n = 500, m1 = 66, m2 = 184, t = 4
27 Correct 2 ms 6492 KB [OK, Yes] n = 500, m1 = 248, m2 = 252, t = 1
28 Correct 1 ms 6608 KB [OK, Yes] n = 500, m1 = 248, m2 = 252, t = 1
29 Correct 2 ms 6492 KB [OK, Yes] n = 500, m1 = 205, m2 = 295, t = 1
30 Correct 291 ms 61832 KB [OK, Yes] n = 1000000, m1 = 183472, m2 = 66528, t = 7
31 Correct 262 ms 61284 KB [OK, Yes] n = 1000000, m1 = 206211, m2 = 43789, t = 6
32 Correct 226 ms 61184 KB [OK, Yes] n = 1000000, m1 = 229445, m2 = 20555, t = 7
33 Correct 364 ms 94644 KB [OK, No] n = 1000000, m1 = 261335, m2 = 238665, t = 2
34 Correct 528 ms 99288 KB [OK, Yes] n = 1000000, m1 = 374819, m2 = 125181, t = 3
35 Correct 466 ms 98616 KB [OK, Yes] n = 1000000, m1 = 88376, m2 = 411624, t = 3
36 Correct 1 ms 6500 KB [OK, Yes] n = 500, m1 = 125, m2 = 125, t = 2
37 Correct 646 ms 75592 KB [OK, Yes] n = 1000000, m1 = 250000, m2 = 250000, t = 2
38 Correct 198 ms 45568 KB [OK, Yes] n = 1000000, m1 = 94957, m2 = 94938, t = 12
39 Correct 282 ms 51584 KB [OK, Yes] n = 1000000, m1 = 94972, m2 = 95007, t = 10
40 Incorrect 19 ms 14296 KB [No solution found] n = 1000000, m1 = 14064, m2 = 13936, t = 200
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20
2 Correct 1 ms 6748 KB [OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000
3 Correct 1 ms 6748 KB [OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000
4 Correct 2 ms 6744 KB [OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000
5 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000
6 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000
7 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000
8 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000
9 Correct 2 ms 6752 KB [OK, No] n = 5000, m1 = 1006, m2 = 995, t = 5000
10 Correct 2 ms 6748 KB [OK, No] n = 5000, m1 = 1017, m2 = 984, t = 5000
11 Correct 2 ms 6884 KB [OK, No] n = 5000, m1 = 1495, m2 = 1506, t = 5000
12 Correct 2 ms 6876 KB [OK, Yes] n = 5000, m1 = 974, m2 = 1026, t = 2501
13 Correct 2 ms 6748 KB [OK, Yes] n = 5000, m1 = 1022, m2 = 978, t = 2501
14 Correct 2 ms 6892 KB [OK, Yes] n = 5000, m1 = 1019, m2 = 981, t = 2501
15 Correct 2 ms 7004 KB [OK, Yes] n = 5000, m1 = 1298, m2 = 1367, t = 2501
16 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1301, m2 = 1360, t = 2501
17 Correct 2 ms 7004 KB [OK, Yes] n = 5000, m1 = 1320, m2 = 1315, t = 2501
18 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1195, m2 = 1135, t = 2501
19 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1148, m2 = 1202, t = 2501
20 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1147, m2 = 1179, t = 2501
21 Correct 2 ms 7008 KB [OK, No] n = 5000, m1 = 1163, m2 = 1146, t = 2501
22 Correct 2 ms 7004 KB [OK, No] n = 5000, m1 = 1145, m2 = 1184, t = 2501
23 Correct 2 ms 6872 KB [OK, No] n = 5000, m1 = 1172, m2 = 1150, t = 2501
24 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 12, m2 = 9, t = 3
25 Correct 1 ms 6492 KB [OK, Yes] n = 10, m1 = 4, m2 = 2, t = 2
26 Correct 1 ms 6612 KB [OK, Yes] n = 10, m1 = 6, m2 = 0, t = 2
27 Correct 1 ms 6492 KB [OK, Yes] n = 10, m1 = 2, m2 = 4, t = 1
28 Correct 1 ms 6504 KB [OK, No] n = 20, m1 = 4, m2 = 11, t = 2
29 Correct 1 ms 6500 KB [OK, Yes] n = 20, m1 = 7, m2 = 8, t = 1
30 Correct 2 ms 6504 KB [OK, Yes] n = 20, m1 = 7, m2 = 8, t = 2
31 Correct 1 ms 6628 KB [OK, Yes] n = 20, m1 = 0, m2 = 10, t = 2
32 Correct 1 ms 6500 KB [OK, Yes] n = 20, m1 = 4, m2 = 6, t = 2
33 Correct 1 ms 6500 KB [OK, Yes] n = 20, m1 = 9, m2 = 1, t = 2
34 Correct 1 ms 6504 KB [OK, Yes] n = 20, m1 = 10, m2 = 9, t = 2
35 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 9, m2 = 10, t = 2
36 Correct 1 ms 6616 KB [OK, Yes] n = 20, m1 = 0, m2 = 0, t = 3
37 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 5, m2 = 4, t = 3
38 Correct 1 ms 6492 KB [OK, Yes] n = 9, m1 = 4, m2 = 3, t = 3
39 Correct 1 ms 6612 KB [OK, Yes] n = 20, m1 = 8, m2 = 8, t = 3
40 Correct 1 ms 6620 KB [OK, Yes] n = 20, m1 = 9, m2 = 7, t = 3
41 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 9, m2 = 10, t = 7
42 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 7, m2 = 10, t = 8
43 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 13, m2 = 10, t = 4
44 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 9, m2 = 9, t = 8
45 Correct 1 ms 6492 KB [OK, Yes] n = 20, m1 = 10, m2 = 11, t = 3
46 Correct 1 ms 6624 KB [OK, Yes] n = 20, m1 = 11, m2 = 11, t = 3
47 Correct 1 ms 6492 KB [OK, Yes] n = 500, m1 = 197, m2 = 53, t = 2
48 Correct 1 ms 6492 KB [OK, Yes] n = 500, m1 = 189, m2 = 61, t = 3
49 Correct 1 ms 6492 KB [OK, No] n = 500, m1 = 66, m2 = 184, t = 4
50 Correct 2 ms 6492 KB [OK, Yes] n = 500, m1 = 248, m2 = 252, t = 1
51 Correct 1 ms 6608 KB [OK, Yes] n = 500, m1 = 248, m2 = 252, t = 1
52 Correct 2 ms 6492 KB [OK, Yes] n = 500, m1 = 205, m2 = 295, t = 1
53 Correct 291 ms 61832 KB [OK, Yes] n = 1000000, m1 = 183472, m2 = 66528, t = 7
54 Correct 262 ms 61284 KB [OK, Yes] n = 1000000, m1 = 206211, m2 = 43789, t = 6
55 Correct 226 ms 61184 KB [OK, Yes] n = 1000000, m1 = 229445, m2 = 20555, t = 7
56 Correct 364 ms 94644 KB [OK, No] n = 1000000, m1 = 261335, m2 = 238665, t = 2
57 Correct 528 ms 99288 KB [OK, Yes] n = 1000000, m1 = 374819, m2 = 125181, t = 3
58 Correct 466 ms 98616 KB [OK, Yes] n = 1000000, m1 = 88376, m2 = 411624, t = 3
59 Correct 1 ms 6500 KB [OK, Yes] n = 500, m1 = 125, m2 = 125, t = 2
60 Correct 646 ms 75592 KB [OK, Yes] n = 1000000, m1 = 250000, m2 = 250000, t = 2
61 Correct 198 ms 45568 KB [OK, Yes] n = 1000000, m1 = 94957, m2 = 94938, t = 12
62 Correct 282 ms 51584 KB [OK, Yes] n = 1000000, m1 = 94972, m2 = 95007, t = 10
63 Incorrect 19 ms 14296 KB [No solution found] n = 1000000, m1 = 14064, m2 = 13936, t = 200
64 Halted 0 ms 0 KB -