/ SeriousOJ /

Record Detail

Memory Exceeded


  
# Status Time Cost Memory Cost
#1 Memory Exceeded ≥312ms ≥256.016 MiB
#2 Memory Exceeded ≥483ms ≥256.016 MiB

Code

// Author: Shawn Das Shachin-->(shawn_das)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define OPTIMIZE_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define setbit(x) __builtin_popcount(x);
#define printp(v) { for(auto &it : v) std::cout << it.first << " " << it.second << std::endl; }
#define printarr(arr) { for(auto &it : arr) std::cout << it << " "; std::cout << std::endl; }
ll compute[10000000];
ll compute2[10000000];
ll compute3[10000000];
ll compute4[10000000];

void cal() {
    ll k = 2;
    int i = 1;
    compute[i] = k;

    while (k < 1e18 && i + 1 < 10000000) {
        i++;
        k += (i + 1);
        compute[i] = k;
    }
}

void cal2() {
    ll k = compute[9999999];  
    int i = 0;
    while (k < 1e18 && i + 1 < 10000000) {
        i++;
        k += (9999999 + i + 1);  
        compute2[i] = k;
    }
}

void cal3() {
    ll k = compute2[9999999];  
    int i = 0;
    while (k < 1e18 && i + 1 < 10000000) {
        i++;
        k += (9999999 + 10000000 + i + 1);
        compute3[i] = k;
    }
}

void cal4() {
    ll k = compute3[9999999];  
    int i = 0;
    while (k < 1e18 && i + 1 < 10000000) {
        i++;
        k += (9999999 + 20000000 + i + 1); 
        compute4[i] = k;
    }
}

bool bs(ll n, ll arr[]) {
    ll left = 1, right = 10000000;
    while (left <= right) {
        ll mid = left + (right - left) / 2;
        if (arr[mid] == n) return true;
        else if (arr[mid] < n) left = mid + 1;
        else right = mid - 1;
    }
    return false;
}

void solve(){
    ll n;
    cin >> n;

    if(bs(n, compute) || bs(n, compute2) || bs(n, compute3) || bs(n, compute4))
        cout << 'b' << endl;
    else
        cout << 'a' << endl;
}

int main() {
    OPTIMIZE_IO;
    int t;
    cin >> t;
    cal();
    cal2();
    cal3();
    cal4();
    while(t--){
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1223 C. Infinity Sequence
Contest
Happy New Year 2026
Language
C++17 (G++ 13.2.0)
Submit At
2026-01-06 16:35:46
Judged At
2026-01-06 16:35:46
Judged By
Score
0
Total Time
≥483ms
Peak Memory
≥256.016 MiB