QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#130490#1949. Simple Cron Speckaruna#AC ✓2ms3656kbC++171.9kb2023-07-24 12:33:422023-07-24 12:33:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-24 12:33:44]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3656kb
  • [2023-07-24 12:33:42]
  • 提交

answer

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

const int MAXN = 90909;
bool b[MAXN];
int f(int hh, int mm, int ss) {
    return 3600 * hh + 60 * mm + ss;
}
vector<int> parse(string s, int m) {
    if (s == "*") {
        vector<int> r;
        for (int i = 0; i < m; i++) r.push_back(i);
        return r;
    }
    vector<string> token;
    string buf;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == ',') {
            token.push_back(buf);
            buf = "";
        }
        else {
            buf += s[i];
        }
    }
    if (buf.size()) token.push_back(buf);

    vector<int> r;
    for (auto s : token) {
        bool f = false;
        for (int i = 0; i < s.size(); i++)
            if (s[i] == '-') f = true;
        
        if (!f) {
            int x = 0;
            for (int i = 0; i < s.size(); i++)
                x = 10 * x + (s[i] - '0');
            r.push_back(x);
        }
        else {
            int x = 0, y = 0;
            bool g = false;
            for (int i = 0; i < s.size(); i++) {
                if (s[i] == '-') g ^= 1;
                else {
                    if (!g) x = 10 * x + (s[i] - '0');
                    else y = 10 * y + (s[i] - '0');
                }
            }
            for (int i = x; i <= y; i++) r.push_back(i);
        }
    }
    return r;
}
int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    int T; cin >> T;
    int a1 = 0, a2 = 0;
    while (T--) {
        string h, m, s; cin >> h >> m >> s;
        vector<int> vh, vm, vs;
        vh = parse(h, 24);
        vm = parse(m, 60);
        vs = parse(s, 60);
        a2 += vh.size() * vm.size() * vs.size();
        for (int hh : vh) for (int mm : vm) for (int ss : vs)
            b[f(hh, mm, ss)] = 1;
    }
    for (int i = 0; i < MAXN; i++) a1 += b[i];
    cout << a1 << ' ' << a2;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3600kb

input:

3
* 5 15,30,45
6,12,18 30 0
8-17 0 30

output:

85 85

result:

ok single line: '85 85'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

22
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37
19 1 37

output:

1 22

result:

ok single line: '1 22'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

24
2 55 56
0 13 2
4 8 35
16 43 48
5 28 58
8 40 7
3 59 6
7 32 20
6 37 16
15 39 23
20 42 15
22 26 10
17 57 52
21 0 44
11 33 14
18 17 49
19 25 34
9 45 9
14 24 31
10 4 27
12 29 22
1 21 50
23 54 18
13 11 12

output:

24 24

result:

ok single line: '24 24'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

100
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* ...

output:

86400 8640000

result:

ok single line: '86400 8640000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

8
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,2...

output:

86400 691200

result:

ok single line: '86400 691200'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

9
8 5 0
* 30 0
* 0,15,30,45 30
9-17 0 0
6,8-17,19,22 30 30
9-17 30 0
0 0 10-19
18-23 0 30,57-59
0-5 1-5 1

output:

188 216

result:

ok single line: '188 216'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

5
5,7-11,21 15,45 10
10,14,16 0-2,15,30-33 29,59
* 29,59 *
18 0 9,14-21,29,45-47,58
0-1,13,22 10,34,46,48 15,24,33,47,54-58

output:

3100 3100

result:

ok single line: '3100 3100'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

5
7,14-19,21 11-14,33-38,43 56
* 54-56 2
3,4,8 8 13-16,23,30-32
6 * 15-17
2-7 5,7,23-27 *

output:

2863 2884

result:

ok single line: '2863 2884'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

1
23 59 59

output:

1 1

result:

ok single line: '1 1'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

3
* * 45
3 4-8,50 *
* 49 *

output:

3210 3240

result:

ok single line: '3210 3240'