Submission #328113

#TimeUsernameProblemLanguageResultExecution timeMemory
328113Sparky_09Rigged Roads (NOI19_riggedroads)C++17
0 / 100
2083 ms9708 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ios_base::sync_with_stdio(false); #ifdef LOCAL_DEFINE freopen("input.txt", "r", stdin); #endif int n, e; cin >> n >> e; vector<tuple<int,int,int>> adj(e+1); for(int i = 0; i < e; i++){ int a,b; cin>>a>>b; adj[i] = make_tuple(a,b,i+1); } vector<int> v(n); for(int i = 0; i < n-1; i++){ cin >> v[i]; } sort(v.begin(), v.end()); int best = INT_MAX; vector<int> ans(n+3, 0); for(int i = 0; i < n-1; i++){ int a,b,c,sum=0; tie(a,b,c) = adj[v[i]-1]; int oldv = c, newv = 1; int diff = oldv - newv; //cerr << diff << ' ' << oldv << ' ' << newv << ' ' << i << ' ' << v[i] << '\n'; //cerr << a << ' ' << b << ' ' << c << ' ' << v[i] << '\n'; sum += 1; for(int j = 0; j < n-1; j++){ if(i==j) continue; int a1,b1,c1; tie(a1,b1,c1) = adj[v[j]-1]; sum += ((c1-diff+e)%e); } if(sum<best){ for(int i = 1; i <= e; i++){ ans[i] = ((i-diff+e)%e); } } } for(int i = 1; i <= e; i++) cout << (ans[i]==0?e:ans[i]) << ' '; cout << '\n'; }
#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...