Submission #912339

# Submission time Handle Problem Language Result Execution time Memory
912339 2024-01-19T10:09:15 Z Arshi Reconstruction Project (JOI22_reconstruction) C++17
0 / 100
2 ms 5976 KB
/**********************GOD**********************/

#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <iterator>
#include <map>

using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse4")

typedef long long ll;
typedef long double ld;
typedef pair<ll , ll> pll;

#define len                 length()
#define MP                  make_pair
#define fs                  first
#define sc                  second
#define pb                  push_back
#define all(x)              x.begin() , x.end()
#define kill(x)             cout << x , exit(0)

const ll MOD = 1e9 + 7;
const ll MXN = 2e5 + 4;

int n, m, q;

vector<int> E[MXN];
int pnt[MXN];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    for(int i = 1; i <= m; i ++) {
        int v, u, w; cin >> v >> u >> w;
        E[v].pb(w);
    }
    for(int i = 1; i <= n; i ++)
        sort(all(E[i]));
    
    cin >> q;
    while(q --) {
        int w; cin >> w;
        ll ans = 0;
        for(int i = 1; i < n; i ++) {
            while(pnt[i] < E[i].size() && E[i][pnt[i]] > w)
                pnt[i] ++;
            int x = abs(w - E[i][pnt[i]]);
            x = min(x, abs(w - E[i][pnt[i] + 1])) ? pnt[i] + 1 < E[i].size() : x;
            ans += 1ll * x;
        }
        cout << ans << '\n';
    }

    return 0;
}

/*!
ahkh
*/

Compilation message

reconstruction.cpp: In function 'int main()':
reconstruction.cpp:58:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             while(pnt[i] < E[i].size() && E[i][pnt[i]] > w)
      |                   ~~~~~~~^~~~~~~~~~~~~
reconstruction.cpp:61:64: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             x = min(x, abs(w - E[i][pnt[i] + 1])) ? pnt[i] + 1 < E[i].size() : x;
      |                                                     ~~~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -