Submission #170765

#TimeUsernameProblemLanguageResultExecution timeMemory
170765songcNaan (JOI19_naan)C++14
0 / 100
2 ms408 KiB
#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; __int128 ASDF = 11; 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++){ LL S=0, sum=V[i][1]; for (int j=1; j<=N; 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 (stderr)

naan.cpp: In function 'int main()':
naan.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...