QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736808#7025. How Much Memory Your Code Is Using?SGColin#AC ✓17ms3700kbC++171.7kb2024-11-12 13:30:142024-11-12 13:30:15

Judging History

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

  • [2024-11-12 13:30:15]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:3700kb
  • [2024-11-12 13:30:14]
  • 提交

answer

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

inline int rd() {
    int x = 0;
    bool f = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) f |= (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    return f ? -x : x;
}

#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

map<string, int> sz;

int testcase;

inline void input(string &s) {
    s = "";
    char c = getchar();
    bool start = false;
    while (c != ';') {
        if (start) s += c;
        else if (isalpha(c) || c == '_') {start = true; s += c;}
        c = getchar();
    }
}

inline void work() {
    int n = rd();
    ll ans = 0;
    string s;
    rep(i, 1, n) {
        input(s);
        string type = "", element = "";
        bool space = false;
        per(i, s.length(), 0) {
            if (s[i] == ' ' && !space) {space = true; continue;}
            space ? type += s[i] : element += s[i];
        }
        reverse(all(type));
        reverse(all(element));
        int amount = 0;
        for (auto c : element) {
            if (!isdigit(c)) continue;
            amount = amount * 10 + (c - '0');
        }
        if (!amount) amount = 1;
        ans += 1ll * sz[type] * amount;
    }
    printf("Case #%d: %lld\n", ++testcase, (ans + 1023) / 1024);
}

int main() {
    sz["bool"] = sz["char"] = 1;
    sz["int"] = sz["float"] = 4;
    sz["long long"] = sz["double"] = 8;
    sz["__int128"] = sz["long double"] = 16;
    per(t, rd(), 1) work();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3700kb

input:

2
8
bool a;
char b;
int c;
long long d;
__int128 e;
float f;
double g;
long double h;
1
int a[1000];

output:

Case #1: 1
Case #2: 4

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 17ms
memory: 3700kb

input:

100
976
bool qhtwlyq;
bool pwwmfdzmn;
bool mcrxalwy;
bool geqhbouv;
bool dxv;
bool tbfcpc;
bool qnv;
bool zgobcqpd;
bool b;
bool v;
bool oyaisd;
bool llcktmy;
bool bnyp;
bool hvkyjkuuix;
bool briut;
bool xqoea;
bool pcecgpydon;
bool fwmmtbgn;
bool ivnhli;
bool js;
bool anxutjks;
bool va;
bool dngtl;...

output:

Case #1: 1
Case #2: 1
Case #3: 4
Case #4: 8
Case #5: 16
Case #6: 4
Case #7: 8
Case #8: 16
Case #9: 92383
Case #10: 96778
Case #11: 382422
Case #12: 750000
Case #13: 1492188
Case #14: 378907
Case #15: 707032
Case #16: 1546875
Case #17: 3
Case #18: 4
Case #19: 12
Case #20: 26
Case #21: 50
Case #22: 12...

result:

ok 100 lines