Submission #1041712

# Submission time Handle Problem Language Result Execution time Memory
1041712 2024-08-02T07:19:57 Z vjudge1 Segway (COI19_segway) C++17
0 / 100
18 ms 4700 KB
#warning Check FastIO
#ifdef ONLINE_JUDGE
    #pragma GCC optimize("Ofast")
    #pragma GCC target("avx,avx2,fma")
#endif
#include <iostream>
#include <algorithm>
#include <climits>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <random>
#include <chrono>
#include <iomanip>
#include <vector>
#include <fstream>
using namespace std;
#define vll vector<ll>
#define sll set<ll>
#define vstr vector<string>
#define ll long long
#define ld long double
#define supra main
#define pb push_back
#define add insert
#define rall(x) rbegin(x),rend(x)
#define all(x) (x).begin(),(x).end()
#define I ios_base::sync_with_stdio(false);
#define Hear cin.tie(NULL);
#define Shots cout.tie(NULL);
#define Ratatatata
#define bits_on(a) (__builtin_popcountll(a))
#define mx_pw2(a) (__builtin_ctzll(a))
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());  
#define SHUFFLE(v) shuffle(all(v), RNG); 
const ll inf=LLONG_MAX;
void input(vll& a)
{
    for(auto& i:a)
        cin>>i;
}
void pyn(bool a)
{
    cout<<(a?"YES":"NO")<<endl;
}
ll powmod(ll a,ll b,ll modulo)
{
  if(b==0){
    return 1;
  }
  ll temp=powmod(a,b/2,modulo);
  if(b%2==0){
    return (temp*temp)%modulo;
  }
  else{
    return (a*((temp*temp)%modulo))%modulo;
  }
}

bool Prime(ll n){
    for (ll i = 2; i*i <= n; i++)
        if (n % i == 0)
            return false;
    return (n>1);
}
const int N=2005;
const int M=305;
ll dp[N][M];
ll boost[N][M];
ll speed[N][3];
bool booster[M];
void solve()
{
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>speed[i][0];
		cin>>speed[i][1];
		cin>>speed[i][2];
	}
	ll m;
	cin>>m;
	for(int j=0;j<m;j++)
	{
		ll x;
		cin>>x;
		booster[x]=1;
	}
	set<pair<ll,pair<ll,ll>>> order_dp;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<M;j++)
		{
			dp[i][j]=1e10;
			boost[i][j]=0;
		}
		dp[i][0]=0;
	}
	for(int j=0;(j+1)<M;j++)
	{
		order_dp.clear();
		for(int i=0;i<n;i++)
			order_dp.insert({dp[i][j],{i,j}});
		while(order_dp.size()>0)
		{
			auto it=*begin(order_dp);
			order_dp.erase(begin(order_dp));
			int i=it.second.first;
			int j=it.second.second;
			if((j+1)>=M)continue;
			if(boost[i][j]>0)
			{
				// We just boost 
				dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
				boost[i][j+1]=boost[i][j]-1;
			}
			else
			{
				// cnt ahead of
				int sm=0; 
				for(int ii=0;ii<n;ii++)
				{
					if(dp[ii][j+1]<=dp[i][j])
					{
						sm++;
						sm%=20;
					}
				}
				boost[i][j]=sm;
				if(boost[i][j]>0 and booster[j]==1)
				{
					dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
					boost[i][j+1]=boost[i][j]-1;
				}
				else
				{
					boost[i][j]=0;
					int seg=-1;
					{
						//Plays a important Role
						if(j<100)
						{
							seg=0;
						}
						else if(j<200)
							seg=1;
						else
							seg=2;
					}
					dp[i][j+1]=min(dp[i][j+1],dp[i][j]+speed[i][seg]);
					boost[i][j+1]=boost[i][j];				
				}
				// We cnt how many i such that dp[i][j+1]<=dp[i][j]
				// by the current time they are ahead of 
			}
		}
	}

	for(int i=0;i<n;i++)
		cout<<dp[i][300]<<'\n';
}
int supra(){
    I Hear Shots Ratatatata
    ll tqwertyuiop=1;
    for(int tp=1;tp<=tqwertyuiop;tp++)
    {
        // cout<<"Case #"<<tp<<": ";
        solve();
    }
    return 0;
}
/*
Bro use only in a emergency 
this is kind of hacking
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
*/

Compilation message

segway.cpp:1:2: warning: #warning Check FastIO [-Wcpp]
    1 | #warning Check FastIO
      |  ^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 18 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2520 KB Output is correct
3 Incorrect 0 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 18 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -