Submission #1295234

#TimeUsernameProblemLanguageResultExecution timeMemory
1295234eldaees131313KOVANICE (COI15_kovanice)C++20
Compilation error
0 ms0 KiB
////////////////////////////// Author:eldaee, coder_viper
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define str string
#define vec vector
#define dou double
#define ld long double
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define YES cout << "YES" << '\n'
#define Yes cout << "Yes" << '\n'
#define NO cout << "NO" << '\n'
#define No cout << "No" << '\n'
#define gcd __gcd
#define all(x) x.begin(),x.end()
#define eldaee ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

/*

*/

void solve() {
    int n, m, vv;
    cin >> n >> m >> vv;

    vec<int> v(m+1, 0);
    vec<vec<int>> vec(m+1);
    vec<pair<int,int>> z;
    for (int i = 0; i < vv; i++) {
        string s;
        cin >> s;
        int a = 0, b = 0;
        int pos = 0;
        while (s[pos] >= '0' && s[pos] <= '9') { 
                a = a*10 + (s[pos]-'0'); pos++; 
        }
        char c = s[pos]; pos++;
        while (s[pos] >= '0' && s[pos] <= '9') { 
                b = b*10 + (s[pos]-'0'); pos++; 
        }
        if (c == '=') {
            z.pb({a,b});
        } 
        else if (c == '<') {
            vec[a].pb(b);
        }
    }
    for (auto p : z) {
        int a = p.first, b = p.second;
        int t = max(v[a], v[b]);
        v[a] = t;
        v[b] = t;
        for (int i = 1; i <= m; i++) {
            if (v[i] == v[a]) {
                v[i] = t;
            }
        }
    }
    for (int i = 1; i <= m; i++) {
        for (auto b : vec[i]) {
            if (v[i] == 0) {
                v[i] = 1;
            }
            if (v[b] == 0) {
                v[b] = v[i]+1;
            } 
            else {
                v[b] = max(v[b], v[i]+1);
            }
        }
    }

    for (int i = 1; i <= m; i++) {
        if (v[i] > 0 && v[i] <= n) {
            cout << "K" << v[i] << "\n";
        } 
        else {
            cout << "?\n";
        }
    }
}

signed main() {
    eldaee
    
    solve();
}

Compilation message (stderr)

kovanice.cpp: In function 'void solve()':
kovanice.cpp:31:21: error: expected primary-expression before '>' token
   31 |     vec<pair<int,int>> z;
      |                     ^~
kovanice.cpp:31:24: error: 'z' was not declared in this scope
   31 |     vec<pair<int,int>> z;
      |                        ^
kovanice.cpp:53:29: error: 'b' was not declared in this scope
   53 |         int t = max(v[a], v[b]);
      |                             ^