QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#473304#7752. The Only Way to the DestinationztttttCompile Error//C++146.1kb2024-07-12 01:11:102024-07-12 01:11:11

Judging History

你现在查看的是最新测评结果

  • [2024-07-12 01:11:11]
  • 评测
  • [2024-07-12 01:11:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+10,M=1e6+10;
struct S{
	int x1,x2,y;
}s[N];
vector<pair<int,int>>v[M];
vector<int>vv[M];
int cnt,cnt1,zt[M],cot,ztt[M],pre[M],zqx,mp[M];
//struct SS{
//	int s,x,djg;
//}p[M]; 
pair<int,int>p[M];
string ans;
int flag;
int find(int x){
	if(pre[x]==0){
		return x;
	}else{
		pre[x]=find(pre[x]);
		return pre[x];
	}
}
bool cmp(S x,S y1){
	return x.y<y1.y;
}
signed main(){
	int n,m,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1;i<=k;i++){
		int x1,x2,y;
		scanf("%lld%lld%lld",&x1,&x2,&y);
		s[i]={x1,x2,y};
	}
	sort(s+1,s+1+k,cmp);
	int cntt=0,syg=s[1].y;
//	cnt++;
//	cnt1++;
//	zt[cnt]=cnt1;
//	p[cnt1]={s[]}
int kt=s[1].y;
if(kt>=3){
	cout<<"NO"<<endl;
	return 0;
}
int kw=s[k].y;
if(m-kw>=2){
	cout<<"NO"<<endl;
	return 0;
}

if(kw-kt>=2*(k-1)+1){
	cout<<"NO"<<endl;
	return 0;
}
    if(m>=2*k+2){
    	cout<<"NO"<<endl;
    	return 0;
	}
	int qd=1;
	//puts("fuck");
	int ix=max(1,kt-1);
	int id=min(m,kw+1);
	for(int i1=ix;i1<=id;i1++){
		int i=i1-ix+1;
		int syg=1;
		for(int j=qd;j<=k;j++){
			if(s[j].y==i1){
				if(s[j].x1>syg){
					v[i].push_back({syg,s[j].x1-1});
					cnt1++;
					vv[i].push_back(cnt1);
				}
				syg=s[j].x2+1;
			}else{
				qd=j;
				break;
			}
		}
		if(syg<=n){
			v[i].push_back({syg,n});
			cnt1++;
			vv[i].push_back(cnt1);
		}
	}
	//cout<<"fuck"<<endl;
	//cout<<v[1].size()<<endl;
	for(int i=ix;i<id;i++){
		int i1=i-ix+1;
		int cnt=v[i1].size()-1,cot=v[i1+1].size()-1;
		//cout<<cnt<<" "<<cot<<endl;
		int l=0,r=0;
		//cout<<i<<endl;
		while(1){
			//cout<<l<<" "<<r<<endl;
				if(l>cnt||r>cot)break;
				if(v[i1][l].second<v[i1+1][r].first){
					l++;
				}else if(v[i1][l].second-v[i1+1][r].first>=1&&v[i1+1][r].second-v[i1][l].first>=1&&v[i1][l].second-v[i1][l].first>=1){
					ans="NO";
					flag=1;
					break;
				}else if(v[i1][l].second==v[i1+1][r].first){
					if(find(vv[i1][l])==vv[i1][l]&&find(vv[i1+1][r])==vv[i1+1][l]){
//						zqx++;
//						if(zqx>1){
//							ans="NO";
//							flag=1;
//							break;
//						}else{
							
								pre[find(vv[i1][l])]=find(vv[i1+1][r]);
							
//						}
					}else{
						if(find(vv[i1][l])!=find(vv[i1+1][r])){
							pre[find(vv[i1][l])]=find(vv[i1+1][r]);
						}else{
							ans="NO";
							flag=1;
							break;
						}
					}
					l++;
				}else if(v[i1][l].first==v[i1+1][r].second){
					if(find(vv[i1][l])==vv[i1][l]&&find(vv[i1+1][r])==vv[i1+1][l]){
//						zqx++;
//						if(zqx>1){
//							ans="NO";
//							flag=1;
//							break;
//						}else{
							
								pre[find(vv[i1][l])]=find(vv[i1+1][r]);
							
						//}
					}else{
						if(find(vv[i1][l])!=find(vv[i1+1][r])){
							pre[find(vv[i1][l])]=find(vv[i1+1][r]);
						}else{
							ans="NO";
							flag=1;
							break;
						}
					}
					r++;
				}else if(v[i1][l].first>v[i1+1][r].second){
					r++;
				}

			}
			if(flag)break;
	}
//	for(int i=1;i<=k;i++){
//		if(s[i].y==syg&&cntt==0){
//			if(i>=2){
//				if(s[i].x1-s[i-1].x2>1){
//					cnt++;
//					cnt1++;
//					zt[cnt]=cnt1;
//					p[cnt1]={s[i-1].x2+1,s[i].x1-1};
//				}
//			}else{
//					if(s[i].x1>1){
//						cnt++;
//						cnt1++;
//						p[cnt1]={1,s[i].x1-1};
//						zt[cnt]=cnt1;
//					}
//				}
//		}else if(s[i].y!=syg&&cntt==0){
//			cntt++;
//			syg=s[i].y;
//			if(i>=2){
//				if(s[i].x1-s[i-1].x2>1){
//					cot++;
//					cnt1++;
//					ztt[cot]=cnt1;
//					p[cnt1]={s[i-1].x2+1,s[i].x1-1};
//				}
//			}else{
//					if(s[i].x1>1){
//						cot++;
//						cnt1++;
//						p[cnt1]={1,s[i].x1-1};
//						ztt[cot]=cnt1;
//					}
//				}
//		}else if(cntt==1&&s[i].y==syg){
//			if(i>=2){
//				if(s[i].x1-s[i-1].x2>1){
//					cot++;
//					cnt1++;
//					ztt[cot]=cnt1;
//					p[cnt1]={s[i-1].x2+1,s[i].x1-1};
//				}
//			}else{
//					if(s[i].x1>1){
//						cot++;
//						cnt1++;
//						p[cnt1]={1,s[i].x1-1};
//						ztt[cot]=cnt1;
//					}
//				}
//		}else if(cntt>=1&&s[i].y!=syg){
//			int l=1;
//			int r=1;
//			while(1){
//				if(l>cnt||r>cot)break;
//				if(p[zt[l]].second<p[ztt[r]].first){
//					l++;
//				}else if(p[zt[l]].second-p[ztt[r]].first>=1&&p[ztt[r]].second-p[zt[l]].second>=1){
//					ans="NO";
//					flag=1;
//					break;
//				}else if(p[zt[l]].second==p[ztt[r]].first){
//					if(find(zt[l])==0&&find(ztt[r])==0){
//						zqx++;
//						if(zqx>1){
//							ans="NO";
//							flag=1;
//							break;
//						}else{
//							
//								pre[find(zt[l])]=find(ztt[r]);
//							
//						}
//					}else{
//						if(find(zt[l])!=find(ztt[r])){
//							pre[find(zt[l])]=find(ztt[r]);
//						}else{
//							ans="NO";
//							flag=1;
//							break;
//						}
//					}
//					l++;
//				}else if(p[zt[l]].first==p[ztt[r]].second){
//					if(find(zt[l])==0&&find(ztt[r])==0){
//						zqx++;
//						if(zqx>1){
//							ans="NO";
//							flag=1;
//							break;
//						}else{
//							
//								pre[find(zt[l])]=find(ztt[r]);
//							
//						}
//					}else{
//						if(find(zt[l])!=find(ztt[r])){
//							pre[find(zt[l])]=find(ztt[r]);
//						}else{
//							ans="NO";
//							flag=1;
//							break;
//						}
//					}
//					r++;
//				}else if(p[zt[l]].first>p[ztt[r]].second){
//					r++;
//				}
//
//			}	
//			if(flag)break;	
//			cntt++;	
//			for(int j=1;j<=cot;j++)zt[j]=ztt[j];
//			cot=0;
//			syg=s[i].y;
//		}else if(cntt>=1&&s[i].y==syg){
//			if(i>=2){
//				if(s[i].x1-s[i-1].x2>1){
//					cot++;
//					cnt1++;
//					ztt[cot]=cnt1;
//					p[cnt1]={s[i-1].x2+1,s[i].x1-1};
//				}
//			}else{
//					if(s[i].x1>1){
//						cot++;
//						cnt1++;
//						p[cnt1]={1,s[i].x1-1};
//						ztt[cot]=cnt1;
//					}
//				}
//		}
//	}
	if(flag==1)cout<<"NO"<<endl;
	else{
		for(int i=ix;i<=id;i++){
			int i1=i-ix+1;
			for(int j=0;j<vv[i1].size();j++){
				int zy=find(vv[i1][j]);
				if(mp[zy]==0){
					mp[zy]=1;
					zqx++;
				}
				if(zqx>1){
					flag=1;
					break;
				}
			}
		}
		if(flag)cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:63:19: error: no matching function for call to ‘max(int, long long int)’
   63 |         int ix=max(1,kt-1);
      |                ~~~^~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:63:19: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   63 |         int ix=max(1,kt-1);
      |                ~~~^~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:63:19: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   63 |         int ix=max(1,kt-1);
      |                ~~~^~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:63:19: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   63 |         int ix=max(1,kt-1);
      |                ~~~^~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:63:19: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   63 |         int ix=max(1,kt-1);
      |                ~~~^~~~~~~~
answer.code:30:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         scanf("%lld%lld%lld",&n,&m,&k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:33:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |                 scanf("%lld%lld%lld",&x1,&x2,&y);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~