제출 #1120393

#제출 시각아이디문제언어결과실행 시간메모리
1120393vjudge1KOVANICE (COI15_kovanice)C++17
50 / 100
345 ms27340 KiB
/**
██╗░░██╗████████╗██╗░░░░░███╗░░░███╗
██║░░██║╚══██╔══╝██║░░░░░████╗░████║
███████║░░░██║░░░██║░░░░░██╔████╔██║
██╔══██║░░░██║░░░██║░░░░░██║╚██╔╝██║
██║░░██║░░░██║░░░███████╗██║░╚═╝░██║
╚═╝░░╚═╝░░░╚═╝░░░╚══════╝╚═╝░░░░░╚═╝
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define int l
#define f first
#define ara <<" "<<
#define s second
#define endl '\n'
#define l long long
#define pb push_back
#define pairs pair<l,l>
#define all(v) v.begin(),v.end()
#define yesno(v) ((v) ? "YES" : "NO")
#define dbg(x) cout<<#x<<" = "<<x<<endl;
#define filereader() ifstream cin(input);
#define fileprinter() ofstream cout(output);
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);


using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ifstream in;
ofstream out;

l gcd(l a, l b){
    return (b == 0) ? a : gcd(b, a%b);
}

const l N = 3e5 + 5;
const l INF = 1e18;
const l mod = 1e9 + 7;

const string  input =  "input.txt";
const string output = "output.txt";

vector<l>ans(N);
vector<vector<l>>v(N);
vector<l>ch(N);

void dfs(l t ,l k){
    ch[t] = 1;
    ans[t] = k;

    for(l f : v[t]){
        if(ch[f] == 0){
            dfs(f,k);
        }
    }

}

signed main(){
    l n,m,k;


    cin>>n>>m>>k;

    set<l>s;

    while(k--){
        l a,b;
        char c;

        cin>>a>>c>>b;

        if(c == '<'){
            ans[a] = 1;
            ans[b] = 2;

            s.insert(a);
            s.insert(b);


        }
        else if(c == '<'){
            ans[a] = 2;
            ans[b] = 1;

            s.insert(a);
            s.insert(b);

        }
        else{
            v[a].pb(b);
            v[b].pb(a);
        }
    }

    for(auto i : s){
        if(ch[i] == 0){
            dfs(i,ans[i]);
        }
    }


    for(int i = 1; i <= m ; i++){
        if(ans[i] == 0){
            cout<<'?'<<endl;
        }
        else{
            cout<<'K'<<ans[i]<<endl;
        }
    }
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...