# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
237944 |
2020-06-09T12:30:13 Z |
farmerboy |
Naan (JOI19_naan) |
C++14 |
|
546 ms |
101240 KB |
/*
Author: Nguyen Tan Bao
Status:
Idea:
*/
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
const ll MODBASE = 1000000007LL;
const int MAXN = 2010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;
int n, l, v[MAXN][MAXN];
ll num[MAXN][MAXN], den[MAXN][MAXN];
bool choose[MAXN];
vector<int> res;
bool isSmaller(int a, int b, int pos) {
ld realPosB = (ld) num[b][pos] / den[b][pos];
ld realPosA = (ld) num[a][pos] / den[a][pos];
return realPosA < realPosB;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(nullptr);
cin >> n >> l;
FOR(i,1,n)
FOR(j,1,l) cin >> v[i][j];
FOR(i,1,n) {
int s = 0;
FOR(j,1,l) s += v[i][j];
int curS = 0, itr = 0;
FOR(j,1,n) {
while ((ll) curS * n < (ll) s * j) curS += v[i][++itr];
num[i][j] = (ll) itr * n * v[i][itr] - (ll) curS * n + (ll) s * j;
den[i][j] = (ll) n * v[i][itr];
}
}
FOR(i,1,n) {
int vt = 0;
FOR(j,1,n)
if (!choose[j])
if (!vt || isSmaller(j, vt, i)) vt = j;
res.push_back(vt);
choose[vt] = true;
}
FOR(i,0,n-2) cout << num[res[i]][i+1] << ' ' << den[res[i]][i+1] << "\n";
FOR(i,0,n-1) cout << res[i] << ' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
512 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
512 KB |
Output is correct |
15 |
Correct |
7 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
512 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
512 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
512 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
6 ms |
512 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
512 KB |
Output is correct |
20 |
Correct |
5 ms |
512 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
512 KB |
Output is correct |
24 |
Correct |
5 ms |
512 KB |
Output is correct |
25 |
Correct |
5 ms |
512 KB |
Output is correct |
26 |
Correct |
5 ms |
512 KB |
Output is correct |
27 |
Correct |
4 ms |
384 KB |
Output is correct |
28 |
Correct |
6 ms |
384 KB |
Output is correct |
29 |
Correct |
5 ms |
512 KB |
Output is correct |
30 |
Correct |
7 ms |
512 KB |
Output is correct |
31 |
Correct |
5 ms |
512 KB |
Output is correct |
32 |
Correct |
5 ms |
512 KB |
Output is correct |
33 |
Correct |
6 ms |
512 KB |
Output is correct |
34 |
Correct |
5 ms |
512 KB |
Output is correct |
35 |
Correct |
5 ms |
384 KB |
Output is correct |
36 |
Correct |
5 ms |
512 KB |
Output is correct |
37 |
Correct |
5 ms |
512 KB |
Output is correct |
38 |
Correct |
5 ms |
384 KB |
Output is correct |
39 |
Correct |
6 ms |
512 KB |
Output is correct |
40 |
Correct |
5 ms |
384 KB |
Output is correct |
41 |
Correct |
5 ms |
384 KB |
Output is correct |
42 |
Correct |
5 ms |
384 KB |
Output is correct |
43 |
Correct |
45 ms |
14712 KB |
Output is correct |
44 |
Correct |
246 ms |
61304 KB |
Output is correct |
45 |
Correct |
147 ms |
26360 KB |
Output is correct |
46 |
Correct |
25 ms |
3584 KB |
Output is correct |
47 |
Correct |
178 ms |
39288 KB |
Output is correct |
48 |
Correct |
150 ms |
72056 KB |
Output is correct |
49 |
Correct |
53 ms |
25592 KB |
Output is correct |
50 |
Correct |
277 ms |
83448 KB |
Output is correct |
51 |
Correct |
127 ms |
37628 KB |
Output is correct |
52 |
Correct |
259 ms |
74844 KB |
Output is correct |
53 |
Correct |
201 ms |
71544 KB |
Output is correct |
54 |
Correct |
5 ms |
384 KB |
Output is correct |
55 |
Correct |
62 ms |
49152 KB |
Output is correct |
56 |
Correct |
164 ms |
51448 KB |
Output is correct |
57 |
Correct |
136 ms |
45800 KB |
Output is correct |
58 |
Correct |
176 ms |
71160 KB |
Output is correct |
59 |
Correct |
171 ms |
41848 KB |
Output is correct |
60 |
Correct |
525 ms |
100984 KB |
Output is correct |
61 |
Correct |
473 ms |
101112 KB |
Output is correct |
62 |
Correct |
472 ms |
100856 KB |
Output is correct |
63 |
Correct |
503 ms |
101240 KB |
Output is correct |
64 |
Correct |
546 ms |
101112 KB |
Output is correct |
65 |
Correct |
326 ms |
87672 KB |
Output is correct |
66 |
Correct |
340 ms |
87800 KB |
Output is correct |
67 |
Correct |
345 ms |
87928 KB |
Output is correct |
68 |
Correct |
165 ms |
58232 KB |
Output is correct |
69 |
Correct |
228 ms |
51832 KB |
Output is correct |
70 |
Correct |
191 ms |
68728 KB |
Output is correct |
71 |
Correct |
278 ms |
73976 KB |
Output is correct |