QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#260441#7695. Double UpItsJerr#Compile Error//C++173.3kb2023-11-22 09:59:552023-11-22 09:59:56

Judging History

你现在查看的是最新测评结果

  • [2023-11-22 09:59:56]
  • 评测
  • [2023-11-22 09:59:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

void print(__int128 x) {
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

__int128 read() {
    __int128 x = 0;
    string s; cin >> s;
    reverse(s.begin(), s.end());
    while (s.size()) {
        x = x * 10 + s.back() - '0';
        s.pop_back();
    }
    return x;
}

signed main() {
    // cin.tie(0)->sync_with_stdio(0);
    if (fopen("qoj_7695.inp", "r")) {
        freopen("qoj_7695.inp", "r", stdin);
        freopen("qoj_7695.out", "w", stdout);
    }

    #ifdef LOCAL_MACHINE 
        if (fopen("task.inp", "r")) {
            freopen("task.inp", "r", stdin);
            freopen("task.out", "w", stdout);
        }
    #endif

    int n; cin >> n; 
    vector<int> a;
    for (int i = 1; i <= n; ++i) {
        __int128 x = read();
        int cur = 0;
        while (x > 1) {
            ++cur;
            x /= 2;
        }
        a.push_back(cur);
    }

    while (a.size() > 1) {
        int mi = 1e9;
        for (int i : a) mi = min(mi, i);

        bool mod = 0;

        for (int i = 0; i + 1 < a.size(); ++i) if (a[i] == a[i + 1] && a[i] == mi) {
            a.erase(a.begin() + i); a.erase(a.begin() + i); a.insert(a.begin() + i, mi + 1); 
            mod = 1;
            break;
        }

        if (mod) continue;

        for (int i = 0; i < a.size(); ++i) if (a[i] == mi) {
            a.erase(a.begin() + i);
            break;
        }
    }

    __int128 res = 1;
    int val = a.back();
    while (val--) res *= 2;

    print(res);
}

// ඞඞඞඞඞ you sus#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

__int128 read() {
    __int128 x = 0;
    string s; cin >> s;
    while (s.size()) {
        x = x * 10 + s.back() - '0';
        s.pop_back();
    }
    return x;
}

void print(__int128 x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

signed main() {
    // cin.tie(0)->sync_with_stdio(0);
    if (fopen("qoj_7695.inp", "r")) {
        freopen("qoj_7695.inp", "r", stdin);
        freopen("qoj_7695.out", "w", stdout);
    }

    #ifdef LOCAL_MACHINE 
        if (fopen("task.inp", "r")) {
            freopen("task.inp", "r", stdin);
            freopen("task.out", "w", stdout);
        }
    #endif

    int n; cin >> n; 
    vector<int> a;
    for (int i = 1; i <= n; ++i) {
        __int128 x = read();
        int cur = 0;
        while (x > 1) {
            ++cur;
            x /= 2;
        }
        a.push_back(cur);
    }

    while (a.size() > 1) {
        // for (int i : a) cerr << i << " "; cerr << "\n";
        int mi = 1e9;
        for (int i : a) mi = min(mi, i);

        bool mod = 0;

        for (int i = 0; i + 1 < a.size(); ++i) if (a[i] == a[i + 1] && a[i] == mi) {
            a.erase(a.begin() + i); a.erase(a.begin() + i); a.insert(a.begin() + i, mi + 1); 
            mod = 1;
            break;
        }

        if (mod) continue;

        for (int i = 0; i < a.size(); ++i) if (a[i] == mi) {
            a.erase(a.begin() + i);
            break;
        }
    }

    __int128 res = 1;
    int val = a.back();
    while (val--) res *= 2;

    print(res);
}

// ඞඞඞඞඞ you sus

Details

answer.code:80:10: error: redefinition of ‘__int128 read()’
   80 | __int128 read() {
      |          ^~~~
answer.code:11:10: note: ‘__int128 read()’ previously defined here
   11 | __int128 read() {
      |          ^~~~
answer.code:90:6: error: redefinition of ‘void print(__int128)’
   90 | void print(__int128 x) {
      |      ^~~~~
answer.code:6:6: note: ‘void print(__int128)’ previously defined here
    6 | void print(__int128 x) {
      |      ^~~~~
answer.code:99:8: error: redefinition of ‘int main()’
   99 | signed main() {
      |        ^~~~
answer.code:22:8: note: ‘int main()’ previously defined here
   22 | signed main() {
      |        ^~~~
answer.code: In function ‘int main()’:
answer.code:25:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |         freopen("qoj_7695.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:26:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |         freopen("qoj_7695.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:102:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  102 |         freopen("qoj_7695.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:103:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  103 |         freopen("qoj_7695.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~