Submission #201341

# Submission time Handle Problem Language Result Execution time Memory
201341 2020-02-10T08:32:26 Z BThero Naan (JOI19_naan) C++17
5 / 100
7 ms 504 KB
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
                                                  
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;   
typedef pair<int, int> pii;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = (int)2e3 + 5;

ll curS[MAXN], limS[MAXN];

ll A[MAXN], B[MAXN];

ll arr[MAXN][MAXN];

int perm[MAXN];

int n, m;

void solve() {
    scanf("%d %d", &n, &m);

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            scanf("%lld", &arr[i][j]);
            limS[i] += arr[i][j];
            arr[i][j] *= n;
        }                         
    }

    for (int i = 1; i <= n; ++i) {
        perm[i] = i;
    }

    do {        
        int ptr = 1;
        fill(curS + 1, curS + n + 1, 0ll);
        bool ok = 1;

        for (int i = 1; i <= n; ++i) {
            int id = perm[i];
            
            while (ptr <= m && curS[id] + arr[id][ptr] <= limS[id]) {
                curS[id] += arr[id][ptr];
                ++ptr;            
            }             

            if (curS[id] == limS[id]) {
                continue;
            }

            if (ptr > m) {
                ok = 0;
                break;
            }

            ll X = arr[id][ptr];
            ll need = limS[id] - curS[id];
            A[i] = (ptr - 1) * X + need;
            B[i] = X;

            int nx = perm[i + 1];
            curS[nx] += arr[nx][ptr] * (X - need) / X;
            ++ptr;                                                                                                                        
        }                

        if (ok) {
            for (int i = 1; i < n; ++i) {
                printf("%lld %lld\n", A[i], B[i]);
            }

            for (int i = 1; i <= n; ++i) {
                printf("%d ", perm[i]);
            }

            printf("\n");
            return;
        }        
    }
    while (next_permutation(perm + 1, perm + n + 1));

    printf("-1\n");
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Compilation message

naan.cpp: In function 'void solve()':
naan.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
naan.cpp:40:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld", &arr[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 424 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 308 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Incorrect 6 ms 376 KB Integer parameter [name=A_i] equals to 0, violates the range [1, 2000000000000]
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 424 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 308 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Incorrect 6 ms 376 KB Integer parameter [name=A_i] equals to 0, violates the range [1, 2000000000000]
25 Halted 0 ms 0 KB -