Submission #718012

# Submission time Handle Problem Language Result Execution time Memory
718012 2023-04-03T06:53:00 Z hariaakas646 Intercastellar (JOI22_ho_t1) C++17
100 / 100
158 ms 22552 KB
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;

int main()
{
    int n;
    scd(n);
    vi vec(n);
    vector<pair<int, lli>> posv(n);
    frange(i, n)
    {
        scd(vec[i]);
        int c = 0;
        while (vec[i] % 2 == 0)
        {
            vec[i] /= 2;
            c++;
        }
        posv[i] = {vec[i], 1 << c};
    }
    map<pair<lli, lli>, int> quer;
    lli st = 0;
    for (auto p : posv)
    {
        quer[mp(st, st + p.s - 1)] = p.f;
        st += p.s;
    }
    int q;
    scd(q);
    frange(_, q)
    {
        lli x;
        sclld(x);
        x--;
        auto it = quer.upper_bound(mp(x, 1e16));
        it--;
        printf("%d\n", (*it).s);
    }
    // for (auto p : quer)
    // {
    //     // forr(i, p.f.f, p.f.s + 1)
    //     // {
    //     //     printf("%d ", p.s);
    //     // }
    //     printf("%lld %lld %d\n", p.f.f, p.f.s, p.s);
    // }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:39:5: note: in expansion of macro 'scd'
   39 |     scd(n);
      |     ^~~
Main.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:44:9: note: in expansion of macro 'scd'
   44 |         scd(vec[i]);
      |         ^~~
Main.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:61:5: note: in expansion of macro 'scd'
   61 |     scd(q);
      |     ^~~
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:65:9: note: in expansion of macro 'sclld'
   65 |         sclld(x);
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 75 ms 16076 KB Output is correct
4 Correct 56 ms 5480 KB Output is correct
5 Correct 119 ms 18748 KB Output is correct
6 Correct 78 ms 15092 KB Output is correct
7 Correct 119 ms 18844 KB Output is correct
8 Correct 126 ms 19036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 75 ms 16076 KB Output is correct
4 Correct 56 ms 5480 KB Output is correct
5 Correct 119 ms 18748 KB Output is correct
6 Correct 78 ms 15092 KB Output is correct
7 Correct 119 ms 18844 KB Output is correct
8 Correct 126 ms 19036 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 308 KB Output is correct
23 Correct 48 ms 5164 KB Output is correct
24 Correct 72 ms 14556 KB Output is correct
25 Correct 139 ms 22108 KB Output is correct
26 Correct 90 ms 14032 KB Output is correct
27 Correct 85 ms 15040 KB Output is correct
28 Correct 158 ms 22552 KB Output is correct
29 Correct 142 ms 21992 KB Output is correct
30 Correct 66 ms 5392 KB Output is correct
31 Correct 149 ms 22444 KB Output is correct