Submission #879595

#TimeUsernameProblemLanguageResultExecution timeMemory
879595Rafi22World of Tank (innopolis2018_final_E)C++14
100 / 100
1097 ms262144 KiB
#include <bits/stdc++.h> #pragma GCC target ("avx2,fma") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") //#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=1000000007; int mod=1000000007; int mod1=998244353; const int N=1000007; int a[N][2]; map<int,int>M; int DP[3*N][2]; int zkad[3*N][2]; bool blocked[3*N][2]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); vector<int>S; int n,m1,m2,t; cin>>n>>m1>>m2>>t; S.pb(0); S.pb(n+1); for(int i=1;i<=m1;i++) { cin>>a[i][0]; S.pb(a[i][0]); S.pb(a[i][0]-1); S.pb(a[i][0]+1); } for(int i=1;i<=m2;i++) { cin>>a[i][1]; S.pb(a[i][1]); S.pb(a[i][1]-1); S.pb(a[i][1]+1); } sort(all(S)); int k=1; vector<int>d={213769420,0}; M[0]=1; for(int i=1;i<sz(S);i++) { if(S[i]!=S[i-1]) { k++; d.pb(S[i]); } M[S[i]]=k; } 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(DP[i][j]<0) continue; 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; } } // cout<<DP[i][0]<<" "<<DP[i][1]<<" "<<d[i]<<endl; for(int j=0;j<2;j++) { if(DP[i][j]<0) continue; 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 (stderr)

E.cpp: In function 'int main()':
E.cpp:127:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  127 |         for(auto [x,y]:Y) cout<<x<<" "<<y<<endl;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...