Submission #666263

#TimeUsernameProblemLanguageResultExecution timeMemory
666263Chal1shkanKemija (COCI22_kemija)C++14
50 / 50
1 ms340 KiB
# include <bits/stdc++.h> # define pb push_back # define ff first # define ss second # define nl "\n" # define pii pair <int, int> # define pll pair <ll, ll> typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ll maxn = 2e6 + 125; const ll maxl = 20 + 0; const ll inf = 2e9 + 0; const ll mod = 998244353; using namespace std; void ma1n () { set <char> st; map <char, int> mp1, mp2; string s; cin >> s; int pos = s.find('-'); string x = ""; for (int i = 0; i <= pos; ++i) { if (s[i] == '+' || i == pos) { int c = 1; if (x[0] >= '2' && x[0] <= '9') { c = (x[0] - '0'); } for (int i = 0 + (c > 1); i < x.size(); ++i) { if (x[i] >= 'A' && x[i] <= 'Z') { st.insert(x[i]); int val = 1; if (i + 1 < x.size() && (x[i + 1] >= '2' && x[i + 1] <= '9')) { val = (x[i + 1] - '0'); } mp1[x[i]] += (val * c); } } x.clear(); } else { x += s[i]; } } pos += 2; for (int i = pos; i <= s.size(); ++i) { if (s[i] == '+' || i == s.size()) { int c = 1; if (x[0] >= '2' && x[0] <= '9') { c = (x[0] - '0'); } for (int i = 0 + (c > 1); i < x.size(); ++i) { if (x[i] >= 'A' && x[i] <= 'Z') { st.insert(x[i]); int val = 1; if (i + 1 < x.size() && (x[i + 1] >= '2' && x[i + 1] <= '9')) { val = (x[i + 1] - '0'); } mp2[x[i]] += (val * c); } } x.clear(); } else { x += s[i]; } } for (char c : st) { if (mp1[c] != mp2[c]) { cout << "NE" << nl; return; } } cout << "DA" << nl; } int main () { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int ttt = 1; cin >> ttt; for (int test = 1; test <= ttt; test++) { // cout << "Case " << test << ":" << nl; ma1n(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void ma1n()':
Main.cpp:38:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             for (int i = 0 + (c > 1); i < x.size(); ++i)
      |                                       ~~^~~~~~~~~~
Main.cpp:44:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |                     if (i + 1 < x.size() && (x[i + 1] >= '2' && x[i + 1] <= '9'))
      |                         ~~~~~~^~~~~~~~~~
Main.cpp:59:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = pos; i <= s.size(); ++i)
      |                       ~~^~~~~~~~~~~
Main.cpp:61:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         if (s[i] == '+' || i == s.size())
      |                            ~~^~~~~~~~~~~
Main.cpp:68:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             for (int i = 0 + (c > 1); i < x.size(); ++i)
      |                                       ~~^~~~~~~~~~
Main.cpp:74:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |                     if (i + 1 < x.size() && (x[i + 1] >= '2' && x[i + 1] <= '9'))
      |                         ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...