제출 #1232488

#제출 시각아이디문제언어결과실행 시간메모리
1232488peyman_sfKemija (COCI22_kemija)C++20
50 / 50
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vll; typedef pair<ll, ll> pll; const ll maxn = 3e6; const ll mod = 1e9 + 7; const ll inf = 2e18; #define TextIO ifstream fileIn("input.txt"); cin.rdbuf(fileIn.rdbuf()); ofstream fileOut("output.txt"); cout.rdbuf(fileOut.rdbuf()); #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); #define print(x) for (auto i : x) cout << i << ' '; cout << endl #define out(x) {cout << x << endl; return;} #define all(x) (x).begin(), (x).end() #define pb push_back #define endl '\n' ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b);} ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } ll pw(ll a, ll b, ll md = mod) {ll res = 1; b = max(b, 0ll); while(b) {if (b & 1){res = (a * res) % md;} a = (a * a) % md; b >>= 1;} return (res % md);} void solve() { string s; cin >> s; s = "+" + s; ll t = 0; ll x = 1; map<char, ll> cnt, cnt2; ll i = 1; for (; i < s.size(); i++) { if (s[i] == '-') { i++; break; } else { ll d = (s[i] - '0'); if (d >= 0 && d < 10) x = d; else { if (s[i] == '+') x = 1; else { if (i != s.size() - 1 && (s[i + 1] - '0') >= 0 && (s[i + 1] - '0') < 10) { cnt[s[i]] += (s[i + 1] - '0') * x; i++; } else cnt[s[i]] += x; } } } } i++; for (; i < s.size(); i++) { ll d = (s[i] - '0'); if (d >= 0 && d < 10) x = d; else { if (s[i] == '+') x = 1; else { if (i != s.size() - 1 && (s[i + 1] - '0') >= 0 && (s[i + 1] - '0') < 10) { cnt2[s[i]] += (s[i + 1] - '0') * x; i++; } else cnt2[s[i]] += x; } } } if (cnt == cnt2) out("DA"); cout << "NE" << endl; } int main() { FastIO ll t = 1; cin >> t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...