#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 time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2068 ms |
3692 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2073 ms |
5356 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2083 ms |
9708 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2083 ms |
6252 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |