답안 #949353

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949353 2024-03-19T06:49:10 Z MuhammadSaram File Paths (BOI15_fil) C++17
0 / 100
7 ms 1112 KB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
#define in binary_search
#define int long long

int s;

bool check(vector<int> &v,int x)
{
	if (x<s+1)
		return false;
	x-=s+1;
	for (int i=v.size()-2;v[i]>=x;i--)
		if (in(all(v),v[i]-x))
			return true;
	return false;
}

signed main()
{
	int n,m,k;
	cin>>n>>m>>k;
	cin>>s;
	int pd[n+1]={},pathd[n+1]={};
	vector<int> pathf[m];
	map<int,bool> pres;
	for (int i=1;i<=n;i++)
	{
		int a,b;
		cin>>a>>b;
		pd[i]=a;
		pathd[i]=pathd[a]+b+1;
	}
	for (int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		pathf[i].push_back(pathd[a]+b+1);
		while (a)
		{
			pathf[i].push_back(pathd[a]);
			a=pd[a];
		}
		pathf[i].push_back(0);
		reverse(all(pathf[i]));
		for (int j=0;j+1<pathf[i].size();j++)
			pres[pathf[i][j]+s+1]=true;
	}
	for (int i=0;i<m;i++)
	{
		int x=pathf[i].back();
		string ans="NO";
		if (x==k)
			ans="YES";
		else
		{
			for (int j=0;j+1<pathf[i].size();j++)
				if (pres.find(k-(x-pathf[i][j]))!=pres.end())
				{
					ans="YES";
					break;
				}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Compilation message

fil.cpp: In function 'int main()':
fil.cpp:49:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for (int j=0;j+1<pathf[i].size();j++)
      |                ~~~^~~~~~~~~~~~~~~~
fil.cpp:60:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |    for (int j=0;j+1<pathf[i].size();j++)
      |                 ~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -