제출 #1023517

#제출 시각아이디문제언어결과실행 시간메모리
1023517sopaconkSplit the Attractions (IOI19_split)C++17
0 / 100
539 ms1048576 KiB
#include "split.h" #include<bits/stdc++.h> using namespace std; using lli=long long int; #define pb push_back #define deb(x) cout<<#x<<": "<<x<<endl; vector<int> find_split(int n, int a1, int b1, int c1, vector<int> p, vector<int> q) { int m=p.size(); vector<pair<int,int>> ayuda; ayuda.pb({a1,1}); ayuda.pb({b1,2}); ayuda.pb({c1,3}); sort(ayuda.begin(), ayuda.end()); int a=ayuda[0].first; int b=ayuda[1].first; int c=ayuda[2].first; vector<vector<int>> adj (n); for(int i=0;i<m; ++i){ adj[p[i]].pb(q[i]); adj[q[i]].pb(p[i]); } vector<vector<int>> dis (n, vector<int> (n,-1)); for(int i=0; i<n; ++i){ queue<pair<int,int>> q; dis[i][i]=0; q.push({i,0}); while(!q.empty()){ int x=q.front().first; int d=q.front().second; q.pop(); for(int y: adj[x]){ if(dis[i][y]==-1){ dis[i][y]=d+1; q.push({y,d+1}); } } } } vector<int> ans; for(int i=0; i<n; ++i){ // deb(i); int bb=b; int aa=a; vector<int> aux (n,0); vector<bool> vis(n,0); vis[i]=true; aux[i]=2; int maxi=0; int ind=i; for(int j=0; j<n; ++j){ if(dis[i][j]>=maxi){ maxi=dis[i][j]; ind=j; } } vis[ind]=true; aux[ind]=1; // deb(ind); bb--; aa--; priority_queue<pair<int,int>> pq1; priority_queue<pair<int,int>> pq2; for(int x:adj[i]){ // deb(x); if(!vis[x]){ pq1.push({dis[ind][x], x}); } } // deb("_----"); for(int x: adj[ind]){ // deb(x); if(!vis[x]){ pq2.push({dis[i][x], x}); } } // deb("------"); while(bb>0 && !pq1.empty()){ int x=pq1.top().second; // deb(x); pq1.pop(); while(vis[x] && !pq1.empty()){ x=pq1.top().second; // deb(x); pq1.pop(); } // deb("------------------"); if(vis[x]){ break; } aux[x]=2; vis[x]=true; for(int y:adj[x]){ if(!vis[y]){ pq1.push({dis[ind][y], y}); } } bb--; if(aa>0){ if(pq2.empty()) break; x=pq2.top().second; // deb(x); pq2.pop(); while(vis[x] && !pq2.empty()){ x=pq2.top().second; // deb(x); pq2.pop(); } // deb("-----------"); if(vis[x]) break; vis[x]=true; aux[x]=1; for(int y:adj[x]){ if(!vis[y]){ pq2.push({dis[i][y], y}); } } aa--; } } if(aa==0 && bb==0){ ans=aux; break; } } if(ans.size()==0){ vector<int> aux (n,0); return aux; } for(int i=0; i<n; ++i){ ans[i]=ayuda[(ans[i]+2)%3].second; } return ans; }

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

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:22:7: warning: unused variable 'c' [-Wunused-variable]
   22 |   int c=ayuda[2].first;
      |       ^
#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...