Submission #991405

# Submission time Handle Problem Language Result Execution time Memory
991405 2024-06-02T08:44:11 Z onbert Broken Device (JOI17_broken_device) C++17
0 / 100
1 ms 604 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 251;
 
void Anna(int32_t n, long long X, int32_t k, int32_t p[]){
    int m = 37;
    int pwr[m+1];
    pwr[0] = 1;
    for (int i=1;i<=m;i++) pwr[i] = pwr[i-1] * 3;

    int a[n];
    for (int i=0;i<n;i++) a[i] = 1;
    for (int i=0;i<k;i++) a[p[i]] = 0;
    k = 0;
    for (int i=0;i<n;i++) if (!a[i] || !a[i^1]) {
        a[i] = 0;
        if (i%2==0) k++;
    }
    // cout << k << endl;
    if (k>=38) {
        int Y = X/pwr[33];
        // cout << "test " << Y << endl;
        int pro = 1;
        for (int i=0;i<75;i++) if (!a[i*2]) pro = pro * (i+1) % M;
        bool done = false;
        for (int i=0;i<75;i++) {
            for (int j=i+1;j<75;j++) {
                if ((i+1)*(j+1)*pro % M == Y && a[i*2] && a[j*2]) {
                    a[i*2] = a[i*2+1] = a[j*2] = a[j*2+1] = 0;
                    done = true;
                    X %= pwr[33];
                    break;
                }
            }
            if (done) break;
        }
        assert(done);
    }
    int cur = 0;
    for (int i=0;i<n;i+=2) {
        int val = X % 3;
        int x = 1, y = 1;
        if (val==0) x = 0, y = 1;
        if (val==1) x = 1, y = 0;
        if (((!a[i]) && x) || ((!a[i+1]) && y)) {
            a[i] = a[i+1] = 0;
            continue;
        }
        a[i] = x, a[i+1] = y;
        X /= 3;
        cur++;
    }
    // for (int i=0;i<n;i++) cout << a[i]; cout << endl;
    for (int i=0;i<n;i++) Set(i, (int32_t)a[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 251;
 
long long Bruno(int32_t n, int32_t a[]){
    int m = 37;
    int pwr[m+1];
    pwr[0] = 1;
    for (int i=1;i<=m;i++) pwr[i] = pwr[i-1] * 3;
    int k = 0;
    for (int i=0;i<n;i+=2) k += (!a[i] && !a[i+1]);
    int x = 0;
    if (k>=38) {
        int prod = 1;
        for (int i =0;i<75;i++) if (!a[i*2] && !a[i*2+1]) prod = prod * (i+1) % M;
        x += prod * pwr[33];
        // cout << prod << endl;
        m = 32;
    }
    int cur = 0;
    for (int i=0;i<n && cur<=m;i+=2) if (a[i]==1 || a[i+1]==1) {
        if (a[i]==1 && a[i+1]==0) x += pwr[cur];
        if (a[i]==1 && a[i+1]==1) x += 2 * pwr[cur];
        cur++;
    }
    return x;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
3 Runtime error 1 ms 604 KB Execution killed with signal 6
4 Runtime error 1 ms 604 KB Execution killed with signal 6
5 Runtime error 1 ms 604 KB Execution killed with signal 6
6 Runtime error 1 ms 604 KB Execution killed with signal 6
7 Runtime error 1 ms 604 KB Execution killed with signal 6
8 Runtime error 1 ms 604 KB Execution killed with signal 6
9 Runtime error 1 ms 604 KB Execution killed with signal 6
10 Runtime error 1 ms 604 KB Execution killed with signal 6
11 Runtime error 1 ms 604 KB Execution killed with signal 6
12 Runtime error 0 ms 604 KB Execution killed with signal 6
13 Runtime error 1 ms 604 KB Execution killed with signal 6
14 Runtime error 1 ms 604 KB Execution killed with signal 6
15 Runtime error 1 ms 604 KB Execution killed with signal 6
16 Runtime error 1 ms 604 KB Execution killed with signal 6
17 Runtime error 1 ms 604 KB Execution killed with signal 6
18 Runtime error 1 ms 604 KB Execution killed with signal 6
19 Runtime error 0 ms 400 KB Execution killed with signal 6
20 Runtime error 1 ms 600 KB Execution killed with signal 6
21 Runtime error 1 ms 600 KB Execution killed with signal 6
22 Runtime error 0 ms 604 KB Execution killed with signal 6
23 Runtime error 1 ms 604 KB Execution killed with signal 6
24 Runtime error 1 ms 604 KB Execution killed with signal 6
25 Runtime error 0 ms 604 KB Execution killed with signal 6
26 Runtime error 1 ms 604 KB Execution killed with signal 6
27 Runtime error 1 ms 600 KB Execution killed with signal 6
28 Runtime error 1 ms 604 KB Execution killed with signal 6
29 Runtime error 1 ms 604 KB Execution killed with signal 6
30 Runtime error 1 ms 604 KB Execution killed with signal 6
31 Runtime error 1 ms 604 KB Execution killed with signal 6
32 Runtime error 0 ms 604 KB Execution killed with signal 6
33 Runtime error 1 ms 604 KB Execution killed with signal 6
34 Runtime error 1 ms 604 KB Execution killed with signal 6
35 Runtime error 1 ms 604 KB Execution killed with signal 6
36 Runtime error 1 ms 604 KB Execution killed with signal 6
37 Runtime error 1 ms 604 KB Execution killed with signal 6
38 Runtime error 1 ms 604 KB Execution killed with signal 6
39 Runtime error 1 ms 600 KB Execution killed with signal 6
40 Runtime error 1 ms 600 KB Execution killed with signal 6