# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
311938 | 2020-10-12T03:31:23 Z | decoqwq | Vrtić (COCI18_vrtic) | C++14 | 18 ms | 372 KB |
#include <bits/stdc++.h> using namespace std; int to[160],st[160],n,a[160],ans; int gans() { int qwq=0; for(int i=1;i<=n;i++) { qwq=max(qwq,abs(st[a[i]]-st[a[to[i]]])); } return qwq; } void SA() { double Temp=3000; ans=gans(); while(Temp>1e-4) { int x=rand()%n+1,y=rand()%n+1; while(x==y) { x=rand()%n+1,y=rand()%n+1; } swap(a[x],a[y]); int qwq=gans(); if(qwq<ans) { ans=qwq; } else { if(exp((double)(ans-qwq)/Temp)*32767.0<=rand()) { swap(a[x],a[y]); } } Temp*=0.96; } } int main() { srand(19260817); cin>>n; ans=0x3f3f3f3f; for(int i=1;i<=n;i++) { scanf("%d",&to[i]); } for(int i=1;i<=n;i++) { scanf("%d",&st[i]); a[i]=i; } random_shuffle(a+1,a+n+1); for(int i=1;i<=100;i++) { SA(); } cout<<ans<<"\n"; for(int i=1;i<=n;i++) { cout<<st[a[i]]<<" "; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 256 KB | jury has better answer |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 372 KB | jury has better answer |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 256 KB | jury has better answer |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 256 KB | jury has better answer |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 256 KB | jury has better answer |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 256 KB | jury has better answer |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 256 KB | jury has better answer |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 316 KB | jury has better answer |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 256 KB | jury has better answer |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 256 KB | jury has better answer |
2 | Halted | 0 ms | 0 KB | - |