algo

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub kuhaku-space/algo

:heavy_check_mark: test/aoj/challenge/2207.test.cpp

Depends on

Code

// competitive-verifier: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/2207
#include <iostream>
#include <string>
#include <tuple>
#include <unordered_map>
#include "tree/weighted_union_find.hpp"

std::tuple<std::string, std::string, int> input() {
    int tmp, x;
    std::string s, t;
    char c;
    std::cin >> tmp >> s >> c >> tmp >> c >> x >> t;
    return std::make_tuple(s, t, x);
}

int main(void) {
    while (true) {
        int n;
        std::cin >> n;
        if (!n) break;
        std::unordered_map<std::string, int> mp;
        int len = 0;
        weighted_union_find<int> uf(n * 2);
        bool ans = true;
        while (n--) {
            auto [s, t, x] = input();
            if (!mp.count(s)) mp[s] = len++;
            if (!mp.count(t)) mp[t] = len++;
            if (uf.same(mp[s], mp[t])) {
                if (uf.diff(mp[s], mp[t]) != x) { ans = false; }
            } else {
                uf.unite(mp[s], mp[t], x);
            }
        }
        std::cout << (ans ? "Yes" : "No") << '\n';
    }

    return 0;
}
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/resolver.py", line 291, in resolve
    bundled_code = language.bundle(path, basedir=basedir)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus.py", line 242, in bundle
    bundler.update(path)
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 479, in update
    self._resolve(pathlib.Path(included), included_from=path)
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 286, in _resolve
    raise BundleErrorAt(path, -1, "no such header")
competitive_verifier.oj.verify.languages.cplusplus_bundle.BundleErrorAt: tree/weighted_union_find.hpp: line -1: no such header

Test cases

Env Name Status Elapsed Memory
g++ judge_data :heavy_check_mark: AC 7 ms 4 MB
Back to top page