QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#59580#245. Time ZonetreelikestreeAC ✓136ms3564kbC++141.7kb2022-10-31 02:51:562022-10-31 02:52:12

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-31 02:52:12]
  • Judged
  • Verdict: AC
  • Time: 136ms
  • Memory: 3564kb
  • [2022-10-31 02:51:56]
  • Submitted

answer

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

int n, a, b; 
string s; 

void fast_io(void){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void sol(void){
    cin >> n;
    while(n--){
        cin >> a >> b >> s; 
        if(s[3] == '+'){
            int time, diff = 0, idx = 0; 
            
            while(idx < s.size() && s[idx] != '.') idx++; 
            
            if(idx < s.size()){
                diff += 60 * stoi(s.substr(4, idx - 4)); 
                diff += 60 * stoi(s.substr(idx+1)) / 10; 
            }
            else{
                diff += 60 * stoi(s.substr(4)); 
            }
            diff -= 60 * 8; 
            
            time = (60 * a + b + diff + 1440)%1440;
            
            if((time/60) < 10) cout << "0"; 
            cout << time/60;  
            cout << ":"; 
            if((time%60) < 10) cout << "0"; 
            cout << time%60 << "\n";
        }
        else{
            int time, diff = 0, idx = 0; 
            
            while(idx < s.size() && s[idx] != '.') idx++; 
            
            if(idx < s.size()){
                diff -= 60 * stoi(s.substr(4, idx - 4)); 
                diff -= 60 * stoi(s.substr(idx+1)) / 10; 
            }
            else{
                diff -= 60 * stoi(s.substr(4)); 
            }
            diff -= 60 * 8; 
            
            time = (60 * a + b + diff + 1440)%1440;
            if((time/60) < 10) cout << "0"; 
            cout << time/60;  
            cout << ":"; 
            if((time%60) < 10) cout << "0"; 
            cout << time%60 << "\n";
        }
    }
}

int main(void){
    fast_io(); 
    sol(); 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 136ms
memory: 3564kb

input:

406080
0 0 UTC+0
0 0 UTC-0
0 0 UTC+0.1
0 0 UTC-0.1
0 0 UTC+0.2
0 0 UTC-0.2
0 0 UTC+0.3
0 0 UTC-0.3
0 0 UTC+0.4
0 0 UTC-0.4
0 0 UTC+0.5
0 0 UTC-0.5
0 0 UTC+0.6
0 0 UTC-0.6
0 0 UTC+0.7
0 0 UTC-0.7
0 0 UTC+0.8
0 0 UTC-0.8
0 0 UTC+0.9
0 0 UTC-0.9
0 0 UTC+1
0 0 UTC-1
0 0 UTC+1.1
0 0 UTC-1.1
0 0 UTC+1.2
0...

output:

16:00
16:00
16:06
15:54
16:12
15:48
16:18
15:42
16:24
15:36
16:30
15:30
16:36
15:24
16:42
15:18
16:48
15:12
16:54
15:06
17:00
15:00
17:06
14:54
17:12
14:48
17:18
14:42
17:24
14:36
17:30
14:30
17:36
14:24
17:42
14:18
17:48
14:12
17:54
14:06
18:00
14:00
18:06
13:54
18:12
13:48
18:18
13:42
18:24
13:36
...

result:

ok 406080 lines