Submission #170767

# Submission time Handle Problem Language Result Execution time Memory
170767 2019-12-26T10:03:28 Z songc Naan (JOI19_naan) C++14
100 / 100
640 ms 103888 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> pll;

int N, M;
bool chk[2020];
LL V[2020][2020];
pll C[2020][2020];
vector<int> P;

bool comp(pll a, pll b){
	return (__int128)a.first*b.second < (__int128)a.second*b.first;
}

int main(){
	scanf("%d %d", &N, &M);
	for (int i=1; i<=N; i++) for (int j=1; j<=M; j++) scanf("%d", &V[i][j]);
	for (int i=1; i<=N; i++){
		LL S=0, sum=V[i][1];
		for (int j=1; j<=M; j++) S += V[i][j];

		int t=1;
		for (int j=1; j<=N; j++){
			while (sum*N < S*j){
				t++;
				sum += V[i][t];
			}
			LL p = S*j-N*sum+V[i][t]*N*t;
			LL q = V[i][t] * N;
			C[i][j] = pll(p, q);
		}
	}
	for (int i=1; i<N; i++){
		pll Min=pll(1234567890123456ll, 1);
		int k=0;

		for (int j=1; j<=N; j++) if (!chk[j] && comp(C[j][i], Min)) Min = C[j][i], k = j;
		printf("%lld %lld\n", Min.first, Min.second);
		P.push_back(k);
		chk[k] = true;
	}
	for (int x : P) printf("%d ", x);
	for (int i=1; i<=N; i++) if (!chk[i]) printf("%d\n", i);
	return 0;
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:18:72: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'LL* {aka long long int*}' [-Wformat=]
  for (int i=1; i<=N; i++) for (int j=1; j<=M; j++) scanf("%d", &V[i][j]);
                                                                ~~~~~~~~^
naan.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~~
naan.cpp:18:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1; i<=N; i++) for (int j=1; j<=M; j++) scanf("%d", &V[i][j]);
                                                    ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 404 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 408 KB Output is correct
8 Correct 2 ms 408 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 352 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 372 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 508 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 544 KB Output is correct
18 Correct 3 ms 504 KB Output is correct
19 Correct 3 ms 508 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 544 KB Output is correct
22 Correct 3 ms 504 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 476 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 404 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 408 KB Output is correct
8 Correct 2 ms 408 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 352 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 372 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 508 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 632 KB Output is correct
25 Correct 3 ms 504 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 544 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 3 ms 508 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 544 KB Output is correct
37 Correct 3 ms 504 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 3 ms 476 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 3 ms 508 KB Output is correct
43 Correct 52 ms 13436 KB Output is correct
44 Correct 309 ms 63788 KB Output is correct
45 Correct 207 ms 28892 KB Output is correct
46 Correct 32 ms 4060 KB Output is correct
47 Correct 239 ms 42492 KB Output is correct
48 Correct 168 ms 75696 KB Output is correct
49 Correct 72 ms 24056 KB Output is correct
50 Correct 339 ms 95952 KB Output is correct
51 Correct 197 ms 41796 KB Output is correct
52 Correct 387 ms 87204 KB Output is correct
53 Correct 293 ms 81004 KB Output is correct
54 Correct 3 ms 424 KB Output is correct
55 Correct 66 ms 43996 KB Output is correct
56 Correct 251 ms 56488 KB Output is correct
57 Correct 198 ms 49284 KB Output is correct
58 Correct 261 ms 78556 KB Output is correct
59 Correct 234 ms 46224 KB Output is correct
60 Correct 635 ms 96560 KB Output is correct
61 Correct 640 ms 96576 KB Output is correct
62 Correct 638 ms 96372 KB Output is correct
63 Correct 632 ms 96612 KB Output is correct
64 Correct 639 ms 96584 KB Output is correct
65 Correct 482 ms 103764 KB Output is correct
66 Correct 482 ms 103888 KB Output is correct
67 Correct 489 ms 103812 KB Output is correct
68 Correct 237 ms 60160 KB Output is correct
69 Correct 288 ms 56596 KB Output is correct
70 Correct 268 ms 72092 KB Output is correct
71 Correct 414 ms 82464 KB Output is correct