Submission #898351

#TimeUsernameProblemLanguageResultExecution timeMemory
898351devkudawlaLaugh Analysis (IOI16_laugh)C++17
Compilation error
0 ms0 KiB
// AUTHOR->DEV KUDAWLA //---------------------------------------------------- #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order(it return an iterator input is a value), order_of_key(input is index) typedef tree<long long, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #define ll long long int #define vl vector<long long> #define nline cout << "\n" #define pb push_back #define db pop_back #define n_digit(n) (int)log10(n) + 1 #define msb(n) (int)(log2(n)) + 1 // it is 1 based #define pll pair<ll, ll> #define all(x) x.begin(), x.end() #define lt(x) x.size() #define ternary(a, b, c) ((a) ? (b) : (c)) #define yesno(a) a ? cout << "Yes" : cout << "No" #define sroot(a) sqrt((long double)a) #define Max(a, b) max((ll)a, (ll)b) #define Min(a, b) min((ll)a, (ll)b) #define mkp(a, b) make_pair(a, b) #define tbits(x) __builtin_popcountll(x) //---------------------------------------------------- // CODE STARTS HERE //---------------------------------------------------- void solve(bool testCases = true) { ll T = 1; //->TEST CASES if (testCases) cin >> T; while (T--) { string s; cin >> s; ll n = s.size(); vector<ll> dp(n, 0); if (s[0] == 'h' or s[0] == 'a') dp[0] = 1; ll answer = 0; for (ll i = 1; i < n; i++) { if (s[i] == 'h' or s[i] == 'a') { dp[i] = 1; if ((s[i] == 'h' and s[i - 1] == 'a') or (s[i] == 'a' and s[i - 1] == 'h')) dp[i] = Max(dp[i], dp[i - 1] + dp[i]); } answer = Max(answer, dp[i]); } cout << answer; nline; } //-------------------------------------------- // CODE ENDS HERE } //---------------------------------------------------- int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //------------------------------------------------ // initialise_sieve(prime_sieve); //------------------------------------------------ #ifdef LOCAL_COMPILER std::cout << std::fixed << std::setprecision(25); std::cerr << std::fixed << std::setprecision(10); auto start = std::chrono::high_resolution_clock::now(); #endif solve(false); #ifdef LOCAL_COMPILER auto stop = std::chrono::high_resolution_clock::now(); long double duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count(); std::cerr << "Time taken : " << duration / 1e9 << "s" << std::endl; #endif //------------------------------------------------ return 0; } //----------------------------------------------------

Compilation message (stderr)

/usr/bin/ld: /tmp/ccdLSZYh.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccEVTIuk.o:laugh.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccdLSZYh.o: in function `main':
grader.cpp:(.text.startup+0x65): undefined reference to `longest_laugh(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: error: ld returned 1 exit status