Submission #697037

# Submission time Handle Problem Language Result Execution time Memory
697037 2023-02-08T02:01:02 Z minhcool City (JOI17_city) C++17
0 / 100
159 ms 25872 KB
#include "Encoder.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 7e5 + 5;
const int mod = 1e9 + 7, oo = 1e18 + 7;

vector<int> Adj[N];

int sz[N], l[N], r[N], cnt;

double ind = 2;

double arr[N];

int cod[N];

void prep(){
    arr[0] = 1;
    for(int i = 1; ; i++){
        arr[i] = (arr[i - 1] * ind);
        //if(i <= 10) cout << i << " " << arr[i] << '\n';
        if(arr[i] >= 700000) break;
    }
}

void dfs(int u, int p){
    cnt++;
    l[u] = cnt;
    sz[u] = 1;
    for(auto v : Adj[u]){
        if(v == p) continue;
        dfs(v, u);
        sz[u] += sz[v];
    }
    r[u] = cnt;
}

void dfs2(int u, int p){
    for(auto v : Adj[u]){
        if(v == p) continue;
        dfs2(v, u);
    }
    int total = 1;
    for(auto v : Adj[u]){
        if(v != p){
            total += ceil(arr[cod[v]]);
            //cout << v << " " << cod[v] << " " << total << "\n";
        }
    }
    //assert(total <= 100);
    //cout << u << " " << total << "\n";
    while(arr[cod[u]] < (double)total) cod[u]++;
    //cout << cod[u] << "\n";
}

void Encode(int n, int a[], int b[]){
    prep();
    for(int i = 0; i < (n - 1); i++){
        Adj[a[i]].pb(b[i]);
        Adj[b[i]].pb(a[i]);
    }
    dfs(0, 0);
    dfs2(0, 0);
    //for(int i = 0; i < n; i++) cout << cod[i] << " " << l[i] << "\n";
    for(int i = 0; i < n; i++) Code(i, (ll)cod[i] * (ll)250005 + (ll)l[i]);
}

/*

void process(){
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i
}

signed main(){
    ios_base::sync_with_stdio(0);
    freopen("KEK.inp", "r", stdin);
    freopen("KEK.out", "w", stdout);
    cin.tie(0);
    process();
}*/
#include "Device.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 7e5 + 5;
const int mod = 1e9 + 7, oo = 1e18 + 7;

double _ind = 2;

double _arr[N];

void _prep(){
    _arr[0] = 1;
    for(int i = 1; ; i++){
        _arr[i] = (_arr[i - 1] * _ind);
        if(_arr[i] >= 700000) break;
    }
}

void InitDevice(){
    _prep();
}

int Answer(ll x, ll y){
    ll a = x % 250005, b = y % 250005, c = _arr[x / 250005] + a - 1, d = _arr[y / 250005] + b - 1;
    if(a <= b && c >= d) return 1;
    else if(a >= b && c <= d) return 0;
    else return 2;
}

//int n, a[N];

/*

void process(){
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i
}

signed main(){
    ios_base::sync_with_stdio(0);
    freopen("KEK.inp", "r", stdin);
    freopen("KEK.out", "w", stdout);
    cin.tie(0);
    process();
}*/

Compilation message

Encoder.cpp:15:36: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   15 | const int mod = 1e9 + 7, oo = 1e18 + 7;
      |                               ~~~~~^~~

Device.cpp:15:36: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   15 | const int mod = 1e9 + 7, oo = 1e18 + 7;
      |                               ~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 17084 KB Output is correct
2 Incorrect 9 ms 17084 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 25872 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -