제출 #807701

#제출 시각아이디문제언어결과실행 시간메모리
807701AndiRSolar Storm (NOI20_solarstorm)C++14
25 / 100
454 ms145724 KiB
#include <iostream> #include <vector> using namespace std; typedef long long ll; const int Nmax=1000000; int n, s, k, d[Nmax], v[Nmax], r[Nmax]; int st[Nmax+1], sol; ll spd[Nmax], spv[Nmax], mx; vector <int >ad[Nmax+1]; ll dist(int a, int b){ if (a==b) return 0; if (a==0) return spd[b-1]; return spd[b-1]-spd[a-1]; } ll vp(int a, int b){ if (a==0) return spv[b]; return spv[b]-spv[a-1]; } void dfs(int nod, int lev){ st[lev]=nod; if (nod!=n){ int l; if (lev<s) l=n-1; else l=st[lev-s]-1; //cout<<nod<<' '<<l<<'\n'; if (vp(nod, l)>mx){ mx=vp(nod, l); sol=nod; } } for (int i=0; i<ad[nod].size(); i++) dfs(ad[nod][i], lev+1); } int main() { cin>>n>>s>>k; for (int i=0; i<n-1 ;i++) cin>>d[i]; for (int i=0; i<n; i++) cin>>v[i]; spd[0]=d[0]; for (int i=1; i<n-1; i++) spd[i]=spd[i-1]+d[i]; spv[0]=v[0]; for (int i=1; i<n; i++) spv[i]=spv[i-1]+v[i]; ///cautam cel mai din dreapta modul din intervalul k int p1=0; for (int i=0; i<n; i++) while (dist(p1, i)>k) r[p1++]=i-1; for (int i=p1; i<n; i++) r[i]=n-1; ///cream arborele for (int i=0; i<n; i++) ad[r[r[i]]+1].push_back(i); dfs(n, 0); cout<<s<<'\n'; for (int i=0; i<s; i++){ //cout<<sol<<' '; if (sol==n) cout<<n<<' '; else{ cout<<r[sol]+1<<' '; sol=r[r[sol]]+1; } } return 0; }

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

SolarStorm.cpp: In function 'void dfs(int, int)':
SolarStorm.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i=0; i<ad[nod].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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...