# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
278763 |
2020-08-21T20:26:58 Z |
caoash |
Naan (JOI19_naan) |
C++14 |
|
74 ms |
126456 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
struct fr{
__int128 x, y;
fr(__int128 X = 0, __int128 Y = 1){
x = X, y = Y;
ll g = __gcd(x, y);
x /= g, y /= g;
}
friend fr operator+(fr a, fr b){
return fr(a.x * b.y + b.x * a.y, a.y * b.y);
}
friend fr operator-(fr a, fr b){
return fr(a.x * b.y - b.x * a.y, a.y * b.y);
}
friend fr operator*(fr a, fr b){
return fr(a.x * b.x, a.y * b.y);
}
friend fr operator/(fr a, fr b){
return fr(a.x * b.y, a.y * b.x);
}
friend bool operator<(fr a, fr b){
return a.x * b.y < b.x * a.y;
}
};
const int MX = 2005;
bool used[MX]; fr V[MX][MX]; fr need[MX], dist[MX], ans[MX]; int ind[MX];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int N, L; cin >> N >> L;
for (int i = 0; i < N; i++) {
for (int j = 0; j < L; j++) {
int x; cin >> x;
V[i][j] = fr(x);
if (j != 0) V[i][j] = V[i][j] + V[i][j - 1];
}
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (used[j]) {
continue;
}
fr need = V[i][L] * fr(i + 1, N);
int it = lower_bound(V[j], V[j] + L, need) - V[j] - 1;
fr to_add = fr(it) + fr(need - V[j][it]) / fr(V[j][it + 1] - V[j][it]);
if (to_add < ans[i]) {
ans[i] = to_add;
ind[i] = j;
}
}
if(i < N - 1) cout << (int) ans[i].x << " " << (int) ans[i].y << '\n';
used[ind[i]] = true;
}
for (int i = 0; i < N - 1; i++) {
cout << ind[i] + 1 << " ";
}
cout << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
71 ms |
126456 KB |
Integer parameter [name=A_i] equals to -1, violates the range [1, 2000000000000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
74 ms |
126328 KB |
Integer parameter [name=A_i] equals to -1, violates the range [1, 2000000000000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
71 ms |
126456 KB |
Integer parameter [name=A_i] equals to -1, violates the range [1, 2000000000000] |
2 |
Halted |
0 ms |
0 KB |
- |