Submission #100383

#TimeUsernameProblemLanguageResultExecution timeMemory
100383cveleZamjena (COCI18_zamjena)C++14
70 / 70
158 ms11128 KiB
#include <iostream> #include <sstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cctype> #include <cstring> #include <iomanip> #include <bitset> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <list> #include <map> using namespace std; const int N = 100005; int n; string a[N], b[N]; int cnt = 1; int p[N]; int what[N]; map <string, int> id; int fs(int u) { return (p[u] == u ? u : p[u] = fs(p[u])); } void join(int x, int y) { int aa = fs(x), bb = fs(y); if (aa == bb) return; if (what[aa] && what[bb] && (what[aa] != what[bb])) { cout << "NE" << endl; exit(0); } if (!what[aa]) { p[aa] = bb; } else { p[bb] = aa; } } int tonum(string a) { int ans = 0; for (int i = 0; i < a.size(); i++) { ans = ans * 10 + (a[i] - '0'); } return ans; } int main() { cin >> n; for (int i = 0; i < N; i++) p[i] = i; for (int i = 0; i < n; i++) { cin >> a[i]; if (!id[a[i]]) { id[a[i]] = cnt++; } if (isdigit(a[i][0])) { what[id[a[i]]] = tonum(a[i]); } } for (int i = 0; i < n; i++) { cin >> b[i]; if (!id[b[i]]) { id[b[i]] = cnt++; } if (isdigit(b[i][0])) { what[id[b[i]]] = tonum(b[i]); } } for (int i = 0; i < n; i++) { join(id[a[i]], id[b[i]]); } cout << "DA" << endl; return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'int tonum(std::__cxx11::string)':
zamjena.cpp:50:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < a.size(); i++) {
                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...