제출 #1087111

#제출 시각아이디문제언어결과실행 시간메모리
1087111modwwe도로 폐쇄 (APIO21_roads)C++17
31 / 100
2091 ms21452 KiB
#pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> #define int2 long long //#define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar inline int scan() { char c = getchar_unlocked(); int x = 0; while(c<'0'||c>'9') { c=getchar_unlocked(); } while(c>='0'&&c<='9') { x=(x<<1)+(x<<3)+c-'0'; c=getchar_unlocked(); } return x; } void phongbeo(); const int inf=1e9; const int mod2=1e9+9; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; int2 n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid,l2,r2,center; int i,s10,s12; int kk; int el=29; int2 a[100001]; int2 b[100001]; vector<ib> v[100001]; vector<int2> v2; void dfs(int x,int y) { for(auto f:v[x]) { if(f.a!=y) { a[f.a]=f.b; b[f.a]=f.b; dfs(f.a,x) ; } } s8=v[x].size(); s9=max(s9,s8); } void dfs2(int x,int y) { for(auto f:v[x]) { if(f.a!=y) { dfs2(f.a,x); } } for(auto f:v[x]) { if(f.a!=y) { v2.pb(a[f.a]); a[f.a]=b[f.a]; } } sort(v2.begin(),v2.end()); s5=0; s3=v[x].size(); for(int i=1; i<=s3-k; ++i) { s4+=v2[i-1]; s5=v2[i-1]; } s6=max(s3-k+1,1ll); for(int i=s6;i<=v2.size();i++) { if(v2[i-1]>=0) break; s4+=v2[i-1]; } v2.clear(); if(s5>0) a[x]-=s5; } vector<long long > vv; vector<long long> minimum_closure_costs(int N,vector<int> U,vector<int> V,vector<int> W) { n=N; for(int i=1; i<n; i++) { //cin>>l>>r>>s2; l=U[i-1]; r=V[i-1]; s2=W[i-1]; l++; r++; v[l].pb({r,s2}); v[r].pb({l,s2}); s4+=s2; } dfs(1,0); for(int i=0; i<n; i++ ) { if(i!=0&&i<s9) k=i, dfs2(1,0); vv.pb(s4); s4=0; } return vv; } /* main() { freopen("test.inp","r",stdin); freopen("test.ans","w",stdout); int n; cin>>n; vector<int> a1,a2,a3; for(int i=1;i<=n;i++) { int l,r,s2; cin>>l>>r>>s2; a1.pb(l); a2.pb(r); a3.pb(s2); } vector<int2> ve=minimum_closure_costs(n,a1,a2,a3); for(auto x:ve) cout<<x<<"\n"; }*/ /** 5 1 2 1 1 3 4 1 4 3 3 5 2 */

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

roads.cpp: In function 'void dfs2(int, int)':
roads.cpp:112:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |      for(int i=s6;i<=v2.size();i++)
      |                   ~^~~~~~~~~~~
roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:133:18: warning: narrowing conversion of 'r' from 'long long int' to 'int' [-Wnarrowing]
  133 |         v[l].pb({r,s2});
      |                  ^
roads.cpp:133:20: warning: narrowing conversion of 's2' from 'long long int' to 'int' [-Wnarrowing]
  133 |         v[l].pb({r,s2});
      |                    ^~
roads.cpp:134:18: warning: narrowing conversion of 'l' from 'long long int' to 'int' [-Wnarrowing]
  134 |         v[r].pb({l,s2});
      |                  ^
roads.cpp:134:20: warning: narrowing conversion of 's2' from 'long long int' to 'int' [-Wnarrowing]
  134 |         v[r].pb({l,s2});
      |                    ^~
#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...