QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#632484 | #7752. The Only Way to the Destination | realisation | Compile Error | / | / | C++20 | 2.4kb | 2024-10-12 13:27:40 | 2024-10-12 13:27:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
// #define int long long
const int N = 2e6+5, mod = 1e9+7;
vector<pair<int,int>> c[N], v[N];
map<array<int,3>,int> mp;
int fa[N];
int find(int x) {
while(x!=fa[x]) {
x = fa[x] = fa[fa[x]];
} return x;
}
void solve(){
int n, m, k;
cin>>n>>m>>k;
for(int i=1;i<=N-5;i++) fa[i] = i;
for(int i=1;i<=k;i++) {
int l, r, y;
cin>>l>>r>>y;
if(y<=1e6) {
c[y].push_back({l,r});
}
}
if(m==1) {
cout<<"YES"<<endl;
return ;
}
if(m>=5*k) {
cout<<"NO"<<endl;
return ;
}
int cnt = 0;
for(int i=1;i<=m&&i<=2*k+10;i++) {
int l = 1;
for(int j=0;j<c[i].size();j++) {
if(l==n+1) break;
int r = c[i][j].first-1;
if(l<=r) {
v[i].push_back({l,r});
mp[{l,r,i}] = ++cnt;
}
l = c[i][j].second+1;
}
if(l<=n) {
v[i].push_back({l,n});
mp[{l,n,i}] = ++cnt;
}
}
auto ok = [&](int l, int r, int ll, int rr) {
int len;
int s = min(r, rr) - max(l, ll) + 1;
len = max(0ll, s);
return len>=2;
};
for(int i=2;i<=m;i++) {
int len1 = v[i-1].size();
int len2 = v[i].size();
if(v[i-1].empty()) {
continue;
}
else if(v[i].empty()) continue;
for(int j=0;j<len1;j++) {
for(int z=0;z<len2;z++) {
auto [l,r] = v[i-1][j];
auto [ll,rr] = v[i][z];
if(ok(l,r,ll,rr)) {
cout<<"NO"<<endl;
return ;
}
else if(max(l,ll)<=min(r,rr)) {
int x = mp[{l,r,i-1}];
int y = mp[{ll,rr,i}];
int fx = find(x);
int fy = find(y);
if(fx==fy) {
cout<<"NO"<<endl;
return ;
}
fa[fx] = fy;
}
}
}
}
cout<<"YES"<<endl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
// int T;
// cin>>T;
// while(T--)
solve();
}
详细
answer.code: In lambda function: answer.code:58:18: error: no matching function for call to ‘max(long long int, int&)’ 58 | len = max(0ll, s); | ~~~^~~~~~~~ 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:58:18: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) 58 | len = max(0ll, s); | ~~~^~~~~~~~ /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:58:18: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) 58 | len = max(0ll, s); | ~~~^~~~~~~~ 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:58:18: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 58 | len = max(0ll, s); | ~~~^~~~~~~~ /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:58:18: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 58 | len = max(0ll, s); | ~~~^~~~~~~~