This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O2,O3,Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,popcnt,lzcnt,abm,mmx,avx,avx2,fma,bmi,bmi2")
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;
int main() {
fast;
vector<pair<ll, ll>> v;
ll n, m, k;
ll cvb[100005];
memset(cvb, 0, sizeof(cvb));
ll a, b;
char c;
cin >> n >> m >> k;
for (ll i = 0; i < k; i++) {
cin >> a >> c >> b;
if (c == '=') {
v.push_back({a, b});
} else {
cvb[a] = 1;
cvb[b] = 2;
}
}
for (ll j = 0; j < 100; j++) {
for (ll i = 0; i < v.size(); i++) {
ll a = v[i].first, b = v[i].second;
if (cvb[a] != cvb[b] && cvb[a] != 0 && cvb[b] != 0) {
cvb[a] = 0;
cvb[b] = 0;
} else if (cvb[a] != cvb[b] && cvb[a] == 0) {
cvb[a] = cvb[b];
} else if (cvb[a] != cvb[b]) {
cvb[b] = cvb[a];
}
}
}
for (ll i = 1; i <= m; i++) {
if (cvb[i] == 0)
cout << '?' << endl;
else
cout << 'K' << cvb[i] << endl;
}
return 0;
}
Compilation message (stderr)
kovanice.cpp: In function 'int main()':
kovanice.cpp:29:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (ll i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |