Task: | HIIT remains |
Sender: | ContinuedLife |
Submission time: | 2016-05-28 16:39:01 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.29 s | details |
#2 | ACCEPTED | 0.28 s | details |
#3 | ACCEPTED | 0.17 s | details |
#4 | ACCEPTED | 0.06 s | details |
Compiler report
input/code.cpp: In function 'long long unsigned int solve(int, std::string&, int)': input/code.cpp:9:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(start == input.size()) return 0; ^
Code
#include <bits/stdc++.h> #define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(6); using namespace std; #define HIIT 15 unsigned long long table[20][100010]; unsigned long long solve(int curr, string& input, int start){ if(start == input.size()) return 0; if(table[curr][start]) return table[curr][start]; int last = 1; for( ; last < 4; ++last){ int temp = (1 << last)& curr; //cout << temp << endl; if(temp) break; } unsigned long long ans = 0; switch(last){ case 1: if(input[start] == 'T') ans += 1; ans += solve(curr, input, start + 1); break; case 2: if(input[start] == 'I') ans += solve(curr | (1<<1), input, start + 1); ans += solve(curr, input, start+1); break; case 3: if(input[start] == 'I') ans += solve(curr | (1<<2), input, start + 1); ans += solve(curr, input, start+1); break; case 4: if(input[start] == 'H') ans += solve(curr | (1<<3), input, start + 1); ans += solve(curr, input, start+1); break; } table[curr][start] = ans; return ans; } int main(){ _ int TC; cin >> TC; while(TC--){ string input, str; cin >> input; for(int i = 0; i < int(input.size()); ++i){ if(input[i] == 'H' || input[i] == 'I' || input[i] == 'T'){ str.push_back(input[i]); // cout << "get here" << endl; } } // cout << str << endl; memset(table, 0, sizeof table); int curr = 0; cout << solve(curr, str, 0) << 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 ... |
Test 2
Verdict: ACCEPTED
input |
---|
100 TIIHHITTITITIHTHIIIITHIHHIIHTI... |
correct output |
---|
606723862 621369559 655243897 550750615 717769300 ... |
user output |
---|
606723862 621369559 655243897 550750615 717769300 ... |
Test 3
Verdict: ACCEPTED
input |
---|
10 TTHTHHTIIIIIITHIIHIITITTITTIIH... |
correct output |
---|
64668032062669502 66159978956790306 65755072918424640 64408596558953628 65238005187079543 ... |
user output |
---|
64668032062669502 66159978956790306 65755072918424640 64408596558953628 65238005187079543 ... |
Test 4
Verdict: ACCEPTED
input |
---|
3 HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH... |
correct output |
---|
781234375000000000 4999750003 0 |
user output |
---|
781234375000000000 4999750003 0 |