Submission #879474

#TimeUsernameProblemLanguageResultExecution timeMemory
879474Rafi22World of Tank (innopolis2018_final_E)C++14
0 / 100
1 ms4444 KiB
#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 DP[N][2]; int zkad1[N][2]; int zkad2[N][2]; bool odw[N][2]; int a[N][2]; int nx[N][2]; int last[2]; bool bad[2]; void gg() { cout<<"NIE"; exit(0); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m1,m2,t; cin>>n>>m1>>m2>>t; vector<pair<int,pair<int,int>>>V; for(int i=1;i<=m1;i++) cin>>a[i][0]; for(int i=1;i<=m2;i++) cin>>a[i][1]; m1++,m2++; a[m1][0]=inf; a[m2][1]=inf; for(int i=1;i<=m1;i++) V.pb({a[i][0],{i,0}}); for(int i=1;i<=m2;i++) V.pb({a[i][1],{i,1}}); for(int i=1;i<=m1;i++) DP[i][0]=inf; for(int i=1;i<=m2;i++) DP[i][1]=inf; sort(all(V)); reverse(all(V)); for(auto [q,p]:V) { int i=p.st,j=p.nd; last[j]=i; nx[i][j]=last[j^1]; if(a[i][j]<=t&&a[nx[i][j]][j^1]==a[i][j]) gg(); if(a[i][j]<t&&a[nx[i][j]][j^1]==a[i][j]+1) gg(); if(a[i][j]==t) bad[j]=1; } priority_queue<pair<int,pair<int,int>>>Q; for(int i=1;i<=m1;i++) { if(a[i][0]>t&&!bad[0]) { DP[i][0]=t; Q.push({-DP[i][0],{i,0}}); break; } } for(int i=1;i<=m2;i++) { if(a[i][1]>t&&!bad[1]) { DP[i][1]=t; Q.push({-DP[i][1],{i,1}}); break; } } while(sz(Q)>0) { int i=Q.top().nd.st,j=Q.top().nd.nd; int x=-Q.top().st; Q.pop(); if(a[i][j]==inf) break; if(DP[i][j]>=a[i][j]) continue; if(DP[i][j]!=x) continue; if(DP[i][j]+t<DP[i+1][j]) { DP[i+1][j]=DP[i][j]+t; Q.push({-DP[i+1][j],{i+1,j}}); } int k=nx[i][j]; for(;k>0;k--) { if(a[k][j^1]<=DP[i][j]||a[k][j^1]<a[i-1][j]) break; if(a[k-1][j^1]<a[i][j]-1) { if(max(DP[i][j],a[k-1][j^1]+1)<DP[k][j^1]) { DP[k][j^1]=max(DP[i][j],a[k-1][j^1]+1); Q.push({-DP[k][j^1],{k,j^1}}); } } } } if(DP[m1][0]<a[m1][0]||DP[m2][1]<a[m2][1]) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } /* 100 10 10 6 15 30 31 51 52 53 54 55 99 100 15 30 31 51 52 53 54 55 99 100 */

Compilation message (stderr)

E.cpp: In function 'int main()':
E.cpp:55:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   55 |     for(auto [q,p]:V)
      |              ^
#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...