Submission #568153

#TimeUsernameProblemLanguageResultExecution timeMemory
568153dxz05Kemija (COCI22_kemija)C++14
50 / 50
1 ms340 KiB
//#pragma GCC optimize("Ofast,O2,O3,unroll-loops") //#pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << "[" << H << "]"; debug_out(T...); } #ifdef dddxxz #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif #define SZ(s) ((int)s.size()) #define all(x) (x).begin(), (x).end() #define lla(x) (x).rbegin(), (x).rend() #define bpc(x) __builtin_popcount(x) #define bpcll(x) __builtin_popcountll(x) clock_t startTime; double getCurrentTime() { return (double) (clock() - startTime) / CLOCKS_PER_SEC; } #define MP make_pair typedef long long ll; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const double eps = 0.000001; const int MOD = 998244353; const int INF = 1000000101; const long long LLINF = 1223372000000000555; const int N = 1e6 + 3e2; const int M = 1222; vector<int> convert(string s){ int n = s.size(); vector<int> cnt(26, 0); for (int i = 0; i < n; i++){ if (s[i] < 'A') continue; int x = 1; if (i < n - 1 && s[i + 1] <= '9') x = s[i + 1] - '0'; cnt[s[i] - 'A'] += x; } if (s[0] <= '9'){ for (int &i : cnt) i *= s[0] - '0'; } return cnt; } vector<int> operator+ (vector<int> a, vector<int> b){ for (int i = 0; i < 26; i++) a[i] += b[i]; return a; } void solve(int TC) { string s; cin >> s; s += '+'; vector<int> left(26), right(26); int n = s.size(); string t; bool flag = false; for (int i = 0; i < n; i++){ if (s[i] == '+' || s[i] == '-'){ if (!flag) left = left + convert(t); else right = right + convert(t); t.clear(); continue; } if (s[i] == '>'){ flag = true; continue; } t += s[i]; } cout << (left == right ? "DA\n" : "NE\n"); } int main() { startTime = clock(); ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef dddxxz freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int TC = 1; cin >> TC; for (int test = 1; test <= TC; test++) { //debug(test); //cout << "Case #" << test << ": "; solve(test); } cerr << endl << "Time: " << int(getCurrentTime() * 1000) << " ms" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...