제출 #1115490

#제출 시각아이디문제언어결과실행 시간메모리
1115490EfeBabagilJobs (BOI24_jobs)C++14
0 / 100
62 ms33436 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N=1e5+5; const int mod=1e9+7; vector<int> arr[N]; int vis[N]; stack<int> st; void dfs(int x) { vis[x]=1; for(int i=0;i<arr[x].size();i++) { if(!vis[i]) dfs(i); } st.push(x); } int32_t main() { int n,s; cin>>n>>s; vector<array<int,3>> jobs(n+1); vector<int> visd(n+1); int mon=s; jobs[0]={0,-1,0}; visd[0]=1; for(int i=1;i<=n;i++) { int a,b; cin>>a>>b; arr[i].push_back(b); jobs[i]={a,b,i}; if(b==0) { if(a>0) { mon+=a; visd[i]=1; } } } for(int i=1;i<=n;i++) { if(!vis[i]) dfs(i); } vector<int> topo; while(!st.empty()) { topo.push_back(st.top()); //cout<<st.top()<<" "; st.pop(); } for(int i=0;i<=n;i++) { array<int,3> x=jobs[topo[i]]; int prof=0; vector<int> done; while(!visd[x[2]]) { prof+=x[0]; done.push_back(x[2]); x=jobs[x[1]]; } if(prof>0) { for(int i=0;i<done.size();i++) visd[done[i]]=1; mon+=prof; } } cout<<mon-s; return 0; }

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

Main.cpp: In function 'void dfs(long long int)':
Main.cpp:13:18: 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]
   13 |     for(int i=0;i<arr[x].size();i++)
      |                 ~^~~~~~~~~~~~~~
Main.cpp: In function 'int32_t main()':
Main.cpp:70: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]
   70 |             for(int i=0;i<done.size();i++)
      |                         ~^~~~~~~~~~~~
#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...