Submission #1353082

#TimeUsernameProblemLanguageResultExecution timeMemory
1353082vjudge1Intercastellar (JOI22_ho_t1)C++17
25 / 100
617 ms589824 KiB
#include <bits/stdc++.h>

using namespace std;

#define kien long long
#define int long long
#define pb push_back
#define FOR(i, a, b) for (int i = a;i <= b; i++)
#define FORD(i, a, b) for (int i = a;i >= b; i--)
#define pii pair<int, int>
#define dembit(a) __builtin_popcountll(a)
#define task "a"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define debug(x) cout << x << " ";
#define down cout << "\n"
const kien MOD = 1e9 + 7;
const int NTEST = 100;
const int Million = 1e6 + 5;
const int MXN = 2e5 + 5;
const int LOG = 18;
mt19937 rd(chrono::high_resolution_clock::now().time_since_epoch().count());
kien rand(kien l, kien r) {
    assert(l <= r);
    return uniform_int_distribution<kien>(l, r)(rd);
}

kien n, k, m, dem, u, v, a[MXN];
kien maxx, minn, l, r, ans;
vector <int> res;

void change (kien n) {
    int time = 1;
    while (n % 2 == 0) {
        n /= 2;
        time *= 2;
    }
//    cout << time << " ";
    FOR (i, 1, time) res.pb(n);
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    if (fopen(task".inp", "r")) {
        fin(task); fou(task);
    }
    cin >> n;
    FOR (i, 1, n) {
        cin >> a[i];
        if (a[i] % 2 == 0) { change(a[i]); }
        else res.pb(a[i]);
    }
//    for (auto x  : res) cout << x << " ";
//    cout << "\n---------------";

    kien q; cin >> q;
    while (q--) {
        cin >> r;
        cout << res[r - 1] << "\n";
    }

    cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "s ";
}

Compilation message (stderr)

Main.cpp:42:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   42 | main() {
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:47:9: note: in expansion of macro 'fin'
   47 |         fin(task); fou(task);
      |         ^~~
Main.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:47:20: note: in expansion of macro 'fou'
   47 |         fin(task); fou(task);
      |                    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...