Task: | HIIT remains |
Sender: | hefapa_aachen |
Submission time: | 2024-09-28 13:20:02 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.08 s | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
#4 | TIME LIMIT EXCEEDED | -- | details |
Code
// ~/.vim/cpp_template.cpp #include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <string> #define REP(i,a,b) for (int i = a; i < b; i++) // Type Aliases for 1D and 2D vectors with initialization #define vi(n, val) vector<int>(n, val) // 1D vector of ints with size n, initialized to val #define vll(n, val) vector<long long>(n, val) // 1D vector of long longs with size n, initialized to val #define ll long long #define vvi(n, m, val) vector<vector<int>>(n, vector<int>(m, val)) // 2D vector of ints (n x m), initialized to val #define vvll(n, m, val) vector<vector<long long>>(n, vector<long long>(m, val)) // 2D vector of long longs (n x m), initialized to val using namespace std; template <typename T> void pV(const std::vector<T>& vec, const std::string& label = "Vector") { std::cout << label << ": [ "; for (const auto& elem : vec) { std::cout << elem << " "; } std::cout << "]" << std::endl; } using namespace std; void dfs(int s, vector<bool> *visited, vector<int> (*adj)[]) { if ((*visited)[s]) return; (*visited)[s] = true; // process node s for (auto u: (*adj)[s]) { dfs(u, visited, adj); } } /* vector<int> adj[N]; vector<bool> visited(N, false); int u, v; for(int i = 0; i < M;i++){ cin >> u >> v; u--; v--; adj[u].push_back(v); adj[v].push_back(u); } */ int main() { ios::sync_with_stdio(0); cin.tie(0); // Your code starts here int t; cin >> t; REP(i, 0, t){ string s; cin >> s; int n; n = s.size(); vector<int> is(n, 0); long long I= 0; REP(i, 0, n){ if(i > 0){ is[i] = is[i-1]; } if(s[i] == 'I'){ is[i]++; I++; } } //int l = 0, r = n-1; long long res = 0; //while(l<r-2){ REP(l, 0, n){ for(int r=n-1; r >=l+2;r--){ /* while(s[l] != 'H' && l < r-2) l++; while(s[r] != 'T' && l < r-2) r--; */ if(s[l]!= 'H' || s[r] != 'T') continue; int n_is = is[r-1] - is[l]; res+= n_is*(n_is-1)/2; } } cout << res << endl; } return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
100 IIITIIIHITHTHIIITIII HIHIIIIIIHIIITHIIIII ITTIIIITIIIIIIITIIIT IITHITITIHHIITTTIIII ... |
correct output |
---|
12 84 0 37 96 ... |
user output |
---|
12 84 0 37 96 ... Truncated |
Test 2
Verdict: ACCEPTED
input |
---|
100 TIIHHITTITITIHTHIIIITHIHHIIHTI... |
correct output |
---|
606723862 621369559 655243897 550750615 717769300 ... |
user output |
---|
606723862 621369559 655243897 550750615 717769300 ... Truncated |
Test 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
10 TTHTHHTIIIIIITHIIHIITITTITTIIH... |
correct output |
---|
64668032062669502 66159978956790306 65755072918424640 64408596558953628 65238005187079543 ... |
user output |
---|
(empty) |
Test 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
3 HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH... |
correct output |
---|
781234375000000000 4999750003 0 |
user output |
---|
(empty) |