답안 #1120450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1120450 2024-11-28T07:46:51 Z vjudge1 KOVANICE (COI15_kovanice) C++17
50 / 100
322 ms 27208 KB
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define in insert
#define F first
#define S second
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define endl '\n'
#define pii pair<ll,ll>
using namespace std;
const ll INF =1e18, mod = 1e9 + 7, N = 3e5 + 5;
ll vx[N];
vector<ll>g[N];
vector<ll>used(N, 0);
void dfs(ll s,ll w){
    used[s] = 1;
    vx[s] = w;
    for(auto i : g[s]){
        if(!used[i]){
            dfs(i,w);
        }
    } 
}
void solve(){
    ll n,m,v;
    cin >> n >> m >> v;
    set<ll>s;
    while(v--){
        ll x,y;
        char c;
        cin >> x >> c >> y;
        if(c == '<'){
            vx[x] = 1;
            vx[y] = 2;
            s.in(x);
            s.in(y);
        }
        else{
            g[x].pb(y);
            g[y].pb(x);
        }
    }
    for(auto i : s){
        if(used[i] == 0){
            dfs(i,vx[i]);
        }
    }
    for(int i = 1; i <= m; i++){
        if(vx[i] == 0){
            cout << "?" << endl;
        }
        else{
            cout << "K" << vx[i] << endl;
        }
    }
}
int main(){
    fast;
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9808 KB Output is correct
2 Correct 9 ms 9808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 18216 KB Output is correct
2 Correct 112 ms 19528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 10064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 322 ms 27208 KB Output isn't correct
2 Halted 0 ms 0 KB -