# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1094282 |
2024-09-29T09:03:14 Z |
akim9905 |
Naan (JOI19_naan) |
C++17 |
|
2 ms |
604 KB |
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define allr(x) x.rbegin(), x.rend()
#define cmprs(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define endl "\n"
#define sp " "
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define rz resize
#define sz(a) (int)(a.size())
#define clr(a) a.clear()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef tuple<int, int, int> tpi;
typedef tuple<ll, ll, ll> tpl;
typedef pair<double, ll> pdl;
typedef pair<double, int> pdi;
const int dx[] = {1,-1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MAX = 2020; // PLZ CHK!
#define double long double
int N,L,V[MAX][MAX],P[MAX][MAX];
int chk[MAX];
double avg[MAX];
int main() {
fio();
cin>>N>>L;
for (int i=1; i<=N; i++) {
for (int j=1; j<=L; j++) {
cin>>V[i][j];
P[i][j]=P[i][j-1]+V[i][j];
avg[i]+=V[i][j];
}
avg[i]/=1.0*N;
}
const double eps=1e-9;
vector<int> per;
double cur=0.0;
vector<pair<double,int>> ans;
for (int d=1; d<=N && cur+eps<L; d++) {
vector<pair<double,int>> nxts;
int curc=(int)ceil(cur);
for (int i=1; i<=N; i++) {
if (chk[i]) continue;
double le=cur,ri=L,nxt=L;
for (int t=0; t<100; t++) {
double md=(le+ri)/2.0;
double cal=0.0;
int mdf=(int)floor(md),mdc=(int)ceil(md);
cal+=1.0*(curc-cur)*V[i][curc];
cal+=1.0*P[i][mdf]-1.0*P[i][curc];
cal+=1.0*(md-mdf)*V[i][mdc];
if (avg[i]<cal || abs(avg[i]-cal)<eps) {
ri=md;
nxt=md;
}
else le=md;
}
double res=0.0;
int ntf=(int)floor(nxt),ntc=(int)ceil(nxt);
res+=1.0*(curc-cur)*V[i][curc];
res+=1.0*P[i][ntf]-1.0*P[i][curc];
res+=1.0*(nxt-ntf)*V[i][ntc];
if (avg[i]<res || abs(res-avg[i])<eps) {
if (d==N) nxt=L;
nxts.pb({nxt,i});
}
}
if (nxts.empty()) {
cout<<-1;
return 0;
}
sort(all(nxts));
ans.pb({nxts[0].F-cur,nxts[0].S});
cur=nxts[0].F;
chk[nxts[0].S]=1;
}
double seg=0.0;
for (int i=0; i<N-1; i++) {
auto [a,b]=ans[i];
seg+=a;
ll p=seg*1e9, q=1e9;
cout<<p<<sp<<q<<endl;
}
for (auto [a,b]:ans) cout<<b<<sp;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Not a fair distribution. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
480 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
480 KB |
Output is correct |
23 |
Incorrect |
1 ms |
348 KB |
Not a fair distribution. |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Not a fair distribution. |
2 |
Halted |
0 ms |
0 KB |
- |