# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1036373 |
2024-07-27T09:55:11 Z |
beaconmc |
Wiring (IOI17_wiring) |
C++14 |
|
1000 ms |
97688 KB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "wiring.h"
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
ll n,m;
vector<ll> R,B;
map<ll, ll> cache;
map<ll,ll> poses;
ll dp(ll x, ll y){
if (abs(poses[x]-poses[y]) > 7) return 1000000000000000;
if (cache.count(x*1000000+y)) return cache[x*1000000+y];
if (x==n && y==m) return 0;
if (x>=n || y >= m) return 1000000000000000;
return cache[x*1000000+y] = min(dp(x+1,y), min(dp(x,y+1), dp(x+1,y+1))) + abs(R[x] - B[y]);
}
long long min_total_length(std::vector<int> r, std::vector<int> b) {
R.clear();
B.clear();
vector<ll> stuff;
for (auto&i : r) stuff.push_back(i);
for (auto&i : b) stuff.push_back(i);
sort(stuff.begin(), stuff.end());
FOR(i,0,stuff.size()){
poses[stuff[i]] = i;
}
cache.clear();
for (auto&i : r) R.push_back(i);
for (auto&i : b) B.push_back(i);
n = r.size();
m = b.size();
return dp(0,0);
}
Compilation message
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:8:33: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define FOR(i,x,y) for(ll i=x; i<y; i++)
......
37 | FOR(i,0,stuff.size()){
| ~~~~~~~~~~~~~~~~
wiring.cpp:37:2: note: in expansion of macro 'FOR'
37 | FOR(i,0,stuff.size()){
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
22 ms |
2904 KB |
Output is correct |
8 |
Correct |
21 ms |
2908 KB |
Output is correct |
9 |
Correct |
21 ms |
2888 KB |
Output is correct |
10 |
Correct |
23 ms |
2908 KB |
Output is correct |
11 |
Correct |
21 ms |
2908 KB |
Output is correct |
12 |
Correct |
21 ms |
2864 KB |
Output is correct |
13 |
Correct |
21 ms |
2896 KB |
Output is correct |
14 |
Correct |
21 ms |
2908 KB |
Output is correct |
15 |
Incorrect |
20 ms |
2768 KB |
3rd lines differ - on the 1st token, expected: '12164871', found: '12665239' |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
552 KB |
3rd lines differ - on the 1st token, expected: '84383', found: '1000000000029430' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
436 KB |
Output is correct |
3 |
Execution timed out |
1084 ms |
95972 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
1089 ms |
97688 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
22 ms |
2904 KB |
Output is correct |
8 |
Correct |
21 ms |
2908 KB |
Output is correct |
9 |
Correct |
21 ms |
2888 KB |
Output is correct |
10 |
Correct |
23 ms |
2908 KB |
Output is correct |
11 |
Correct |
21 ms |
2908 KB |
Output is correct |
12 |
Correct |
21 ms |
2864 KB |
Output is correct |
13 |
Correct |
21 ms |
2896 KB |
Output is correct |
14 |
Correct |
21 ms |
2908 KB |
Output is correct |
15 |
Incorrect |
20 ms |
2768 KB |
3rd lines differ - on the 1st token, expected: '12164871', found: '12665239' |
16 |
Halted |
0 ms |
0 KB |
- |