Submission #697927

# Submission time Handle Problem Language Result Execution time Memory
697927 2023-02-11T11:58:26 Z doowey Naan (JOI19_naan) C++14
24 / 100
2 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 2010;
int ans[N];
ll V[N][N];
ll S[N][N];
int A[N];
int B[N];
int n, m;

ll get(int i, int j){
    int r = j / n;
    return S[i][r] * 1ll * n + V[i][r + 1] * 1ll * (j % n) ;
}

int main(){
    fastIO;
    //freopen("in.txt", "r", stdin);
    cin >> n >> m;
    vector<int> ord;
    for(int i = 1; i <= n; i ++ ){
        for(int j = 1; j <= m ; j ++ ){
            cin >> V[i][j];
            S[i][j] = V[i][j] + S[i][j - 1];
        }
        ord.push_back(i);
    }
    // 1...n * m
    ll R;
    int las = 0;
    int nx = 0;
    int chk;
    int low;
    int idx;
    for(int i = 1; i + 1 <= n; i ++ ){
        low = (int)1e9;
        idx = -1;
        for(auto x : ord){
            R = S[x][m];
            nx = las;
            for(int lg = 25; lg >= 0; lg -- ){
                chk = (nx + (1 << lg));
                if(chk < n * m){
                    if(get(x, chk) - get(x, las) < R){
                        nx = chk;
                    }
                }
            }
            nx ++ ;
            if(nx < low){
                low = nx;
                idx = x;
            }
        }
        A[i] = low;
        B[i] = n;
        ans[idx] = i;
        vector<int> nn;
        for(auto x : ord){
            if(x != idx){
                nn.push_back(x);
            }
        }
        ord = nn;
        las = low;
    }
    ans[ord[0]] = n;
    for(int i = 1; i <= n - 1; i ++ ){
        cout << A[i] << " " << B[i] << "\n";
    }
    for(int i = 1; i <= n; i ++ ){
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Not a fair distribution.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 392 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Not a fair distribution.
2 Halted 0 ms 0 KB -