제출 #335855

#제출 시각아이디문제언어결과실행 시간메모리
335855hackxsaras꿈 (IOI13_dreaming)C++14
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "dreaming.h" // #include "chrono" #define int long long using namespace std; // using namespace std::chrono; // #pragma GCC target ("avx2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") // #pragma optimization_level 3 // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define pb push_back #define galen_colin {ios_base::sync_with_stdio(false);} #define orz {cin.tie(NULL); cout.tie(NULL);} #define fix(prec) {cout << setprecision(prec) << fixed;} #define mp make_pair #define f first #define s second #define all(v) v.begin(), v.end() typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v); template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; } template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << ""; for(int i = 0; i < v.size(); i++) {if (i) cout << " "; cout << v[i];} return cout << "\n"; } template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) { cin >> p.first; return cin >> p.second; } template<typename A> istream& operator>>(istream& cin, vector<A> &v) { for(auto &x:v)cin>>x; return cin; } // ll min(ll a, int b){return min(a, (ll) b);} // ll min(int a, ll b){return min(b, (ll) a);} // ll max(ll a, int b){return max(a, (ll) b);} // ll max(int a, ll b){return max(b, (ll) a);} void usaco(string filename) { // #pragma message("be careful, freopen may be wrong") freopen((filename + ".in").c_str(), "r", stdin); freopen((filename + ".out").c_str(), "w", stdout); } const ld pi = 3.14159265358979323846; const ll mod = 1000000007; // const ll mod = 998244353; // ll mod; const ll INF = 1e9+7; ll n, m, k, q, l, r, x, y, z; const ll sz = 1e5 + 1; string s, t; ll ans = 0, gc = 0; vector<pair<int,int>> far; vector<int> full, half; vpi adj[sz]; vi path, vis(sz); void getccs(int no, int dep){ vis[no]=1; if(dep>far[gc].second){ far[gc]=make_pair(no,dep); } for(auto i:adj[no]){ if(!vis[i.f]){ getccs(i.f,dep+i.s); } } } //the max.....in this cc //if sum > anything else up till now, but say there are only two edges we can't do better ig int binary_searc(vi& v){ int halfdiff = v.back()/2; int l=0, r = v.size()-1; int ret = v.back(); while(l<=r){ int m = (l+r)/2; if(max(v.back() - v[m], v[m]) < ret){ ret = max(v.back() - v[m], v[m]); } if(v[m] - halfdiff <= 0){ l = m+1; } else { r = m-1; } } return ret; } void farfar(int no, int dep){ vis[no]=1; path.push_back(dep); full[gc] = max(full[gc], path.back()); half[gc] = max(half[gc], binary_searc(path)); for(auto i:adj[no]){ if(!vis[i.f]){ farfar(i.f, dep + i.s); } } path.pop_back(); } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { for(int i=0;i<M;i++){ adj[A[i]].pb({B[i], T[i]}); adj[B[i]].pb({A[i], T[i]}); } n = N; for(int i=0;i<n;i++){ if(!vis[i]){ far.push_back(make_pair(-1,-1)); getccs(i,0); gc++; } } gc=0; vis.clear(); vis.resize(sz, 0); for(int i=0;i<far.size();i++){ full.pb(0), half.pb(0); farfar(far[i].first, 0); gc++; } sort(all(full)); sort(all(half)); ans = full.back(); if(half.size() >= 2) ans = max(ans, half[half.size()-1] + half[half.size()-2] + L); return ans; } // int main() { // int N,M,L; // cin>>N>>M>>L; // int A[M], B[M], T[M]; // for(int i=0;i<M;i++)cin>>A[i]>>B[i]>>T[i]; // cout<< travelTime(N, M, L, A, B, T); // } /* 12 8 2 0 8 4 8 2 2 2 7 4 5 11 3 5 1 7 1 3 1 1 9 5 10 6 3 */

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

dreaming.cpp: In function 'long long int travelTime(long long int, long long int, long long int, long long int*, long long int*, long long int*)':
dreaming.cpp:150:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  150 |     for(int i=0;i<far.size();i++){
      |                 ~^~~~~~~~~~~
dreaming.cpp: In function 'void usaco(std::string)':
dreaming.cpp:57:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   57 |     freopen((filename + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dreaming.cpp:58:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   58 |     freopen((filename + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cc54SsIw.o: In function `main':
grader.c:(.text.startup+0xc9): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status