Submission #1092011

# Submission time Handle Problem Language Result Execution time Memory
1092011 2024-09-22T21:10:48 Z DeathIsAwe Toll (BOI17_toll) C++17
0 / 100
54 ms 40784 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
int segment[131072];


void add(int pos, int a) {
    pos += 65536;
    segment[pos] = a;
    pos /= 2;
    while (pos > 0) {
        if (segment[2*pos + 1] == -1 || segment[2*pos] == -1) {
            segment[pos] = -1;
        } else {
            segment[pos] = segment[2*pos + 1] + segment[2*pos];
        }
        pos /= 2;
    }
}


int find(int a, int b) {
    a += 65536; b += 65536 - 1;
    int val = 0;
    while (a <= b) {
        if (a % 2 == 1) {
            if (segment[a] == -1) {
                val = -1; break;
            }
            val += segment[a++];
        }
        if (b % 2 == 0) {
            if (segment[b] == -1) {
                val = -1; break;
            }
            val += segment[b--];
        }
        a /= 2; b /= 2;
    }
    if (val == 0) {
        return -1;
    }
    return val;
}


int main() {
    int k, n, m, o, d1, d2, t; cin >> k >> n >> m >> o;
    if (k == 1) {
        for (int i=0;i<131072;i++) {
            segment[i] = -1;
        }
        for (int i=0;i<m;i++) {
            cin >> d1 >> d2 >> t;
            add(d1, t);
        }
        cout << segment[65536] << ' ' << segment[65537] << ' ' << segment[32768] << '\n';
        for (int i=0;i<o;i++) {
            cin >> d1 >> d2;
            cout << find(d1, d2);
        }
    }
    int graph[(n + k - 1) / k][k][51][k];
    for (int i=0;i<n+k-1;i++) {
        for (int j=0;j<k;j++) {
            for (int x=0;x<50;x++) {
                for (int y=0;y<k;y++) {
                    graph[i][j][x][y] = 0;
                }
            }
        }
    }
    for (int i=0;i<m;i++) {
        cin >> d1 >> d2 >> t;
        graph[d1/k][d1%k][1][d2%k] = t;
    }
}

Compilation message

toll.cpp: In function 'int main()':
toll.cpp:64:9: warning: variable 'graph' set but not used [-Wunused-but-set-variable]
   64 |     int graph[(n + k - 1) / k][k][51][k];
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 11860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 40784 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 11860 KB Output isn't correct
2 Halted 0 ms 0 KB -