QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#163761 | #7025. How Much Memory Your Code Is Using? | ballance | WA | 1ms | 4112kb | C++23 | 1.4kb | 2023-09-04 14:54:06 | 2023-09-04 14:54:07 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<string>
using namespace std;
const int tran = 1024;
int f(string str)
{
int len = str.size();
for (int i = 0; i < len; i++)
{
char e = str[i];
if (e == ';')
break;
if (e != '\n' && e != '[')
continue;
else if (e == '\n')
break;
else
{
int k = 0;
while (isdigit(e == cin.get()))
{
k = k * 10 + e - '0';
}
return k;
}
}
return 1;
}
int main()
{
int t, cnt = 0, n;
scanf("%d", &t);
string str;
while (t--)
{
scanf("%d", &n);
getchar();
long long num = 0;//字节
while (n--)
{
getline(cin, str);
int len = str.size();
if (str[0] == 'b' || str[0] == 'c')//bool 一字节
{
num += f(str);
}
else if (str[0] == 'i' || str[0] == 'f')
{
num += 4 * f(str);
// cout<<num<<endl;
}
else if (str[0] == 'd') {
num += 8 * f(str);
}
else if (str[0] == '_') {
num += 16 * f(str);
}
else if (str[0] == 'l')
{
if (str[5] == 'd') {//long double 想用 substr 判断double 结果不对emm
num += 16 * f(str);
}
else {
num += 8 * f(str);
}
}
//cout<<num<<endl;
}
//cout<<num<<endl;
int ans;
if (num % tran == 0) ans = num / tran;
else ans = 1 + num / tran;
printf("Case #%d: %d\n", ++cnt, ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4112kb
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: 0
result:
wrong answer 2nd lines differ - expected: 'Case #2: 4', found: 'Case #2: 0'