답안 #776136

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
776136 2023-07-07T10:40:50 Z RecursiveCo Intercastellar (JOI22_ho_t1) C++14
100 / 100
69 ms 14336 KB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long int

signed main() {
    improvePerformance;
    get(n);
    getList(n, nums);
    vector<pair<int, int>> groups;
    forto(n, i) {
        int r = 0;
        while (nums[i] % 2 == 0) {
            r++;
            nums[i] /= 2;
        }
        groups.push_back({1 << r, nums[i]});
    }
    vector<int> p;
    forto(n, i) {
        if (i == 0) p.push_back(groups[i].first);
        else p.push_back(p.back() + groups[i].first);
    }
    get(q);
    forto(q, i) {
        get(x);
        int l = 0;
        int r = n;
        while (r - l >= 1) {
            int middle = (l + r) / 2;
            if (p[middle] < x) l = middle + 1;
            else r = middle; 
        }
        out(groups[l].second);
        out("\n");
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
Main.cpp:22:5: note: in expansion of macro 'get'
   22 |     get(n);
      |     ^~~
Main.cpp:12:40: warning: unnecessary parentheses in declaration of 'nums' [-Wparentheses]
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                        ^
Main.cpp:23:5: note: in expansion of macro 'getList'
   23 |     getList(n, nums);
      |     ^~~~~~~
Main.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
Main.cpp:12:76: note: in expansion of macro 'get'
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                                                            ^~~
Main.cpp:23:5: note: in expansion of macro 'getList'
   23 |     getList(n, nums);
      |     ^~~~~~~
Main.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
Main.cpp:25:5: note: in expansion of macro 'forto'
   25 |     forto(n, i) {
      |     ^~~~~
Main.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
Main.cpp:34:5: note: in expansion of macro 'forto'
   34 |     forto(n, i) {
      |     ^~~~~
Main.cpp:10:23: warning: unnecessary parentheses in declaration of 'q' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
Main.cpp:38:5: note: in expansion of macro 'get'
   38 |     get(q);
      |     ^~~
Main.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
Main.cpp:39:5: note: in expansion of macro 'forto'
   39 |     forto(q, i) {
      |     ^~~~~
Main.cpp:10:23: warning: unnecessary parentheses in declaration of 'x' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
Main.cpp:40:9: note: in expansion of macro 'get'
   40 |         get(x);
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 21 ms 9056 KB Output is correct
4 Correct 27 ms 3532 KB Output is correct
5 Correct 47 ms 10632 KB Output is correct
6 Correct 29 ms 8692 KB Output is correct
7 Correct 48 ms 10688 KB Output is correct
8 Correct 47 ms 10848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 320 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 316 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 21 ms 9056 KB Output is correct
4 Correct 27 ms 3532 KB Output is correct
5 Correct 47 ms 10632 KB Output is correct
6 Correct 29 ms 8692 KB Output is correct
7 Correct 48 ms 10688 KB Output is correct
8 Correct 47 ms 10848 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 324 KB Output is correct
13 Correct 0 ms 320 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 316 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 24 ms 3780 KB Output is correct
24 Correct 32 ms 9432 KB Output is correct
25 Correct 59 ms 13960 KB Output is correct
26 Correct 41 ms 8612 KB Output is correct
27 Correct 37 ms 9796 KB Output is correct
28 Correct 68 ms 14336 KB Output is correct
29 Correct 69 ms 13820 KB Output is correct
30 Correct 33 ms 4396 KB Output is correct
31 Correct 67 ms 14296 KB Output is correct