# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846127 | vjudge1 | KOVANICE (COI15_kovanice) | C++17 | 3 ms | 2648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi>
#define vp vector<pii>
#define sp << " " <<
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back
const int inf = 1e18;
const int MOD = 998244353;
const int N = 3e5+1;
vi dad(N);
int find(int x) {
if (x == dad[x]) return x;
return dad[x] = find(dad[x]);
}
void unite(int x,int y) {
dad[find(x)] = find(y);
}
void solve() {
int n,m,k;
cin >> n >> m >> k;
if (n == 2) {
int better = 0;
F(i,m) dad[i] = i;
dad[0]=0;
while (k--) {
string s;
cin >> s;
string n1,n2;
int seeneq = 0,seensm=0,seenbg=0;
for (auto c : s) {
if (c == '=') {
seeneq = 1;
continue;
}
if (c == '<') {
seensm = 1;
continue;
}
if (c == '>') {
seenbg = 1;
continue;
}
if (seeneq || seenbg || seensm) {
n2+=c;
}else n1+=c;
}
int x = stoi(n1);
int y = stoi(n2);
if (seeneq) {
unite(x,y);
}
else if (seensm){
better = x;
}
else{
better = y;
}
}
vi type(m+1);
for (int i=1;i<=m;i++) {
if (find(i) == find(better)) {
type[i] = 1;
} else if(better)type[i] = 2;
else type[i] =0;
}
F(i,m) {
if (type[i] == 1) {
cout << "K1\n";
}
else if(type[i]){
cout << "K2\n";
}
else {
cout << "?\n";
}
}
}
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef Local
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
freopen("promote.in","r",stdin);
freopen("promote.out","w",stdout);
#endif
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
Compilation message (stderr)
# | 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... |