제출 #888713

#제출 시각아이디문제언어결과실행 시간메모리
888713vjudge1Passport (JOI23_passport)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back using namespace std; signed main(){ ios_base::sync_with_stdio(); cin.tie(0); int n; cin>>n; vector <int> l(n),r(n); for(int i=0;i<n;i++)cin>>l[i]>>r[i]; vector <int> a,b,c; for(int i=0;i<n;i++){ for(int j=l[i];j<=r[i];j++){ a.pb(i+1); b.pb(j); c.pb(1); } } int q;cin>>q; set <pair <int,int> > st; vector <int> ans; while(q--){ int x;cin>>x; vector <int> d(n+1,1e9),p(n+1); d[x]=0; for(int i=0;i<n;i++){ for(int j=0;j<a.size();j++){ if(d[a[j]]!=1e9 && d[b[j]]>d[a[j]]+c[j]){ d[b[j]]=d[a[j]]+c[j]; p[b[j]]=a[j]; } } } int mx=0; set <int> s; for(int i=1;i<=n;i++){ mx=max(mx,d[i]); if(d[i]==1e9)break; int curv=i; while(curv!=x){ curv=p[curv]; s.insert(curv); } } if(mx==1e18)cout<<-1<<"\n"; else cout<<s.size()<<"\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

passport.cpp: In function 'int main()':
passport.cpp:33:26: 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]
   33 |             for(int j=0;j<a.size();j++){
      |                         ~^~~~~~~~~
#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...