Problem:
A - Everlasting Zero
Problem Statement
You are very absorbed in a famous role-playing game (RPG), "Everlasting -Zero-". An RPG is a game in which players assume the roles of characters in a fictional setting. While you play the game, you can forget your "real life" and become a different person.
To play the game more effectively, you have to understand two notions, a
skill point
and a
special command
. A character can boost up by accumulating his experience points. When a character boosts up, he can gain skill points.
You can arbitrarily allocate the skill points to the character's skills to enhance the character's abilities. If skill points of each skill meets some conditions simultaneously (e.g., the skill points of some skills are are greater than or equal to the threshold values and those of others are less than or equal to the values) , the character learns a special command. One important thing is that once a character learned the command, he will never forget it. And once skill points are allocated to the character, you cannot revoke the allocation. In addition, the initial values of each skill is
0
.
The system is so complicated that it is difficult for ordinary players to know whether a character can learn all the special commands or not. Luckily, in the "real" world, you are a great programmer, so you decided to write a program to tell whether a character can learn all the special commnads or not. If it turns out to be feasible, you will be more absorbed in the game and become happy.
Input
The input is formatted as follows.
M
N
K_1
s_{1,1}
cond_{1,1}
t_{1,1}
s_{1,2}
cond_{1,2}
t_{1,2}
...
s_{1,K_1}
cond_{1,K_1}
t_{1,K_1}
K_2
...
K_M
s_{M,1}
cond_{M,1}
t_{M,1}
s_{M,2}
cond_{M,2}
t_{M,2}
...
s_{M,K_M}
cond_{M,K_M}
t_{M,K_M}
The first line of the input contains two integers (
M
,
N
), where
M
is the number of special commands (
1 \leq M \leq 100
),
N
is the number of skills (
1 \leq N \leq 100
).
All special commands and skills are numbered from
1
.
Then
M
set of conditions follows.
The first line of a condition set contains a single integer
K_i
(
0 \leq K_i \leq 100
), where
K_i
is the number of conditions to learn the
i
-th command.
The following
K_i
lines describe the conditions on the skill values.
s_{i,j}
is an integer to identify the skill required to learn the command.
cond_{i,j}
is given by string "<=" or ">=".
If
cond_{i,j}
is "<=", the skill point of
s_{i,j}
-th skill must be less than or equal to the threshold value
t_{i,j}
(
0 \leq t_{i,j} \leq 100
).
Otherwise, i.e. if
cond_{i,j}
is ">=", the skill point of
s_{i,j}
must be greater than or equal to
t_{i,j}
.
Output
Output "Yes" (without quotes) if a character can learn all the special commands in given conditions, otherwise "No" (without quotes).
Sample Input 1
2 2
2
1 >= 3
2 <= 5
2
1 >= 4
2 >= 3
Output for the Sample Input 1
Yes
Sample Input 2
2 2
2
1 >= 5
2 >= 5
2
1 <= 4
2 <= 3
Output for the Sample Input 2
Yes
Sample Input 3
2 2
2
1 >= 3
2 <= 3
2
1 <= 2
2 >= 5
Output for the
...(truncated)

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(A) A.begin(),A.end()
const ll mod = 1e9 + 7;



int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, M; cin >> M >> N;

    vector<vector<int>> V(M);

    vector<vector<array<int, 3>>> P(M);
    rep(i, M) {
        int K;
        cin >> K;
        P[i].resize(K);
        rep(k, K) {
            int n, m;
            string s;
            cin >> n >> s >> m;
            n--;
            int u = 1;
            if (s == "<=")u = -1;
            P[i][k] = { n,m,u };
            rep(j, i+1) {
                for (auto [d, l, v] : P[j]) {
                    if (d != n)continue;
                    if (v == u)continue;
                    if (u == -1 && m < l)V[i].push_back(j);
                    if (v == -1 && l < m)V[j].push_back(i);
                }
            }
        }
    }
    vector<int> E(M, 0);

    rep(i, M) {
        for (int j : V[i]) {
            // cout << i << " " << j << endl;
            E[j]++;
        }
    }
    queue<int> Q;
    rep(i, M) {
        if (E[i] == 0)Q.push(i);
    }
    while (!Q.empty()) {
        int p = Q.front();
        Q.pop();
        for (int j : V[p]) {
            E[j]--;
            if (E[j] == 0)Q.push(j);
        }
    }
    bool OK = 1;
    rep(i, M)if (E[i] > 0)OK = 0;
    cout << (OK ? "Yes" : "No") << endl;
}
accuracy: 1
time_ms: 50
memory_kb: 4136
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
template <typename T>
struct Edge {
    int from, to;
    T cost;
    int idx;
    Edge()
        : from(-1), to(-1), cost(-1), idx(-1) {}
    Edge(int from, int to, const T& cost = 1, int idx = -1)
        : from(from), to(to), cost(cost), idx(idx) {}
    operator int() const {
        return to;
    }
};
template <typename T>
struct Graph {
    Graph(int N)
        : n(N), es(0), g(N) {}
    int size() const {
        return n;
    }
    int edge_size() const {
        return es;
    }
    void add_edge(int from, int to, const T& cost = 1) {
        assert(0 <= from and from < n);
        assert(0 <= to and to < n);
        g[from].emplace_back(from, to, cost, es);
        g[to].emplace_back(to, from, cost, es++);
    }
    void add_directed_edge(int from, int to, const T& cost = 1) {
        assert(0 <= from and from < n);
        assert(0 <= to and to < n);
        g[from].emplace_back(from, to, cost, es++);
    }
    inline vector<Edge<T>>& operator[](const int& k) {
        assert(0 <= k and k < n);
        return g[k];
    }
    inline const vector<Edge<T>>& operator[](const int& k) const {
        assert(0 <= k and k < n);
        return g[k];
    }

   private:
    int n, es;
    vector<vector<Edge<T>>> g;
};
template <typename T>
using Edges = vector<Edge<T>>;
template <typename T>
vector<int> topological_sort(const Graph<T>& g) {
    const int n = g.size();
    vector<int> deg(n);
    for(int i = 0; i < n; ++i) {
        for(const auto& to : g[i]) {
            ++deg[to];
        }
    }
    stack<int> st;
    for(int i = 0; i < n; ++i) {
        if(deg[i] == 0) {
            st.emplace(i);
        }
    }
    vector<int> res;
    res.reserve(n);
    while(!st.empty()) {
        const int p = st.top();
        st.pop();
        res.emplace_back(p);
        for(const Edge<T>& e : g[p]) {
            if(--deg[e.to] == 0) {
                st.emplace(e.to);
            }
        }
    }
    if((int)res.size() != n) return {};
    return res;
}
int main(void) {
    int m, n;
    cin >> m >> n;
    vector<int> k(m);
    vector<vector<int>> s(m), t(m);
    vector<vector<string>> cond(m);
    vector<vector<pair<pair<int, int>, string>>> v(n);
    rep(i, 0, m) {
        cin >> k[i];
        s[i].resize(k[i]);
        t[i].resize(k[i]);
        cond[i].resize(k[i]);
        rep(j, 0, k[i]) {
            cin >> s[i][j] >> cond[i][j] >> t[i][j];
            s[i][j]--;
            v[s[i][j]].push_back({{i, t[i][j]}, cond[i][j]});
        }
    }
    Graph<int> g(m);
    rep(i, 0, n) {
        rep(j1, 0, (int)v[i].size()) {
            rep(j2, 0, (int)v[i].size()) {
                if(v[i][j1].second == "<=" and v[i][j2].second == ">=" and v[i][j1].first.second < v[i][j2].first.second) {
                    g.add_directed_edge(v[i][j1].first.first, v[i][j2].first.first);
                }
            }
        }
    }
    if(!topological_sort(g).empty()) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}
accuracy: 1
time_ms: 10
memory_kb: 7208
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;

using P = pair<int, int>;
using T = tuple<int, int, int>;

int n, m;
vector<P> memo;
vector<vector<T>> v;

bool solve();

int main() {
  cin >> m >> n;
  v.resize(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s, t;
      string com;
      cin >> s >> com >> t;
      v[i].emplace_back(--s, com == ">=", t);
      memo.emplace_back(s, t);
    }
  }
  if (solve())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  vector<int> skill(n, 0), used(m, 0);
  sort(memo.begin(), memo.end());
  for (auto [id, val] : memo) {
    skill[id] = val;
    for (int i = 0; i < m; ++i) {
      bool ch = 1;
      for (auto [s, com, t] : v[i]) {
        if (com && skill[s] < t) ch = 0;
        if (!com && skill[s] > t) ch = 0;
      }
      if (ch) used[i] = 1;
    }
  }
  for (auto p : used)
    if (!p) return 0;
  return 1;
}
accuracy: 0.4158415841584158
time_ms: 60
memory_kb: 3592
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
  [[nodiscard]]
#endif  // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
FixPoint final : private F
{
public:
  template <typename G>
  explicit constexpr FixPoint(G&& g) noexcept
    : F{std::forward<G>(g)}
  {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  noexcept(noexcept(F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif  // !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};  // class FixPoint


#if defined(__cpp_deduction_guides)
template <typename F>
FixPoint(F&&)
  -> FixPoint<std::decay_t<F>>;
#endif  // defined(__cpp_deduction_guides)


namespace
{
  template <typename F>
#if !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  #  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__((warn_unused_result))
#  elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_Check_return_)
_Check_return_
#  endif  // defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#endif  // !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  inline constexpr decltype(auto)
  makeFixPoint(F&& f) noexcept
  {
    return FixPoint<std::decay_t<F>>{std::forward<std::decay_t<F>>(f)};
  }
}  // namespace

vector<int64> G[100];

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int64 M, N;
  cin >> M >> N;
  vector<PII> s(N, PII(-INF, INF));
  vector<vector<int>> lb(M, vector<int>(N, -INF)), ub(M, vector<int>(N, INF));

  REP(i, M) {
    int64 k;
    cin >> k;
    REP(j, k) {
      int64 ss, tt;
      string cond;
      cin >> ss >> cond >> tt; ss--;
      if (cond == "<=") {
        chmin(ub[i][ss], tt);
      } else {
        chmax(lb[i][ss], tt);
      }
    }
  }

  vector<int64> col(M, -1), active(M, 0);
  set<PII> st;

  REP(i, N) {
    REP(j, M) {
      REP(k, M) {
        if (ub[j][i]  < lb[k][i] && st.find(PII(j, k)) == st.end()) {
          G[j].push_back(k);
          st.emplace(j, k);
//          cout << j << " -> " << k << endl;
        }
      }
    }
  }

  auto dfs = makeFixPoint([&](auto f, int v, int c) -> bool {
//    cout << "[" << v << " " << G[v].size() << " " << col[v] << "] ";
    if (col[v] == c) {
      if (active[v]) return false;
      else return true;
    } else if (col[v] != -1) {
      return true;
    }
    col[v] = c;
    active[v] = 1;
    for (auto& u : G[v]) {
//      cout << "(" << v << " " << u << ") ";
      if (!f(u, c)) {
//        cout << v << " : " << u << endl;
        return false;
      }
    }
    active[v] = 0;
    return true;
  });

  REP(i,M) {
//    cout << i << " start" << endl;
    if (!dfs(i, i)) {
      cout << "No" << endl;
      return 0;
    }
//    cout << endl;
//    cout << i << " end" << endl;
  }
  cout << "Yes" << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 4288
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
  [[nodiscard]]
#endif  // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
FixPoint final : private F
{
public:
  template <typename G>
  explicit constexpr FixPoint(G&& g) noexcept
    : F{std::forward<G>(g)}
  {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  noexcept(noexcept(F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif  // !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};  // class FixPoint


#if defined(__cpp_deduction_guides)
template <typename F>
FixPoint(F&&)
  -> FixPoint<std::decay_t<F>>;
#endif  // defined(__cpp_deduction_guides)


namespace
{
  template <typename F>
#if !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  #  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__((warn_unused_result))
#  elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_Check_return_)
_Check_return_
#  endif  // defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#endif  // !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  inline constexpr decltype(auto)
  makeFixPoint(F&& f) noexcept
  {
    return FixPoint<std::decay_t<F>>{std::forward<std::decay_t<F>>(f)};
  }
}  // namespace

vector<int64> G[100];

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int64 M, N;
  cin >> M >> N;
  vector<PII> s(N, PII(-INF, INF));
  vector<vector<int>> lb(M, vector<int>(N, -INF)), ub(M, vector<int>(N, INF));

  REP(i, M) {
    int64 k;
    cin >> k;
    REP(j, k) {
      int64 ss, tt;
      string cond;
      cin >> ss >> cond >> tt; ss--;
      if (cond == "<=") {
        chmin(ub[i][ss], tt);
      } else {
        chmax(lb[i][ss], tt);
      }
    }
  }

  vector<int> state(M, 0);
  set<PII> st;

  REP(i, N) {
    REP(j, M) {
      REP(k, M) {
        if (ub[j][i]  < lb[k][i] && st.find(PII(j, k)) == st.end()) {
          G[j].push_back(k);
          st.emplace(j, k);
//          cout << j << " -> " << k << endl;
        }
      }
    }
  }

  auto dfs = makeFixPoint([&](auto f, int v, int c) -> bool {
    if (state[v] == 1) {
      return false;
    } else if (state[v] == 2) {
      return true;
    }
    state[v] = 1;
    for (auto& u : G[v]) {
//      cout << "(" << v << " " << u << ") ";
      if (!f(u, c)) {
//        cout << v << " : " << u << endl;
        return false;
      }
    }
    state[v] = 2;
    return true;
  });

  REP(i, M) {
//    cout << i << " start" << endl;
    if (!dfs(i, i)) {
      cout << "No" << endl;
      return 0;
    }
//    cout << endl;
//    cout << i << " end" << endl;
  }
  cout << "Yes" << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 4288
final_rank: 13

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const double EPS = 1e-7, PI = acos(-1);
//ここから編集
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  int M, N;
  cin >> M >> N;

  vector<int> K(M);
  vector<vector<int>> s(M), t(M);
  vector<vector<string>> cand(M);
  bool ok = true;
  REP(i,M){
    cin >> K[i];
    s[i].resize(K[i]);
    t[i].resize(K[i]);
    cand[i].resize(K[i]);
    vector<int> tmp(N, INT_MAX);
    REP(j,K[i]){
      cin >> s[i][j] >> cand[i][j] >> t[i][j];
      s[i][j]--;

      if(cand[i][j] == "<=") tmp[s[i][j]] = min(tmp[s[i][j]], t[i][j]);
    }
    REP(j,K[i]){
      if(cand[i][j] == ">=" && tmp[s[i][j]] < t[i][j]) ok = false; 
    }
  }
  if(!ok){
    cout << "No" << endl;
    return 0;
  }
  vector<bool> used(M,false);
  vector<int> skill(N, 0);
  bool update = true;
  
  while(update){
    update = false;

    vector<int> tmp(N, INT_MAX);

    for(int i=0; i<M; i++){
      if(used[i]) continue;
      for(int j=0; j<K[i]; j++){
        if(cand[i][j] == "<="){
          tmp[s[i][j]] = min(tmp[s[i][j]], t[i][j]);
        }
      }
    }
    
    for(int i=0; i<N; i++){
      if(skill[i] > tmp[i]){
        ok = false;
      }else{
        skill[i] = min(skill[i], tmp[i]);
      }
    }
    if(!ok) break;

    for(int i=0; i<M; i++){
      if(used[i]) continue;
      bool f = true;
      for(int j=0; j<K[i]; j++){
        if(cand[i][j] == ">=") f = false;
      }

      if(f){
        used[i] = true;
        update = true;
        break;
      }
    }
    if(!update){
      
      REP(i,M){
        if(used[i]) continue;
        REP(j,N) tmp[j] = skill[j];

        REP(j,K[i]){
          if(cand[i][j] == ">="){
            tmp[s[i][j]] = max(tmp[s[i][j]], t[i][j]);
          }
        }

        bool check = true;
        REP(j,M){
          if(i == j || used[j]) continue;
          
          REP(k,K[j]){

            if(cand[j][k] == "<="){
              if(!(tmp[s[j][k]] <= t[j][k])) {
                check = false;
                
              }
            }
          }
          
        }
        if(check){
          update = true;
          used[i] = true;
          break;
        }
      }
    }
  }

  bool f = true;
  for(int i=0; i<M; i++){
    if(!used[i]) f = false;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3868
final_rank: 10

code_snippet: #include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000300

int main(){
	
	int N,M;
	cin>>M>>N;
	
	vector<vector<int>> l(M,vector<int>(N,0)),r(M,vector<int>(N,100));
	
	rep(i,M){
		int K;
		cin>>K;
		
		rep(j,K){
			int s;
			string c;
			int t;
			cin>>s>>c>>t;
			s--;
			if(c=="<="){
				r[i][s] = min(r[i][s],t);
			}
			else{
				l[i][s] = max(t,l[i][s]);
			}
		}
	}

	vector<int> now(N,0);
	
	while(l.size()!=0){
		while(true){
			bool f = false;
			rep(i,l.size()){
				bool F = true;
				rep(j,N){
					if(l[i][j]<=now[j]&&now[j]<=r[i][j]){
					}
					else{
						F=false;
						break;
					}
				}
				if(F){
					l.erase(l.begin()+i);
					r.erase(r.begin()+i);
					f=true;
					break;
				}
			}
			if(!f)break;
		}
		bool f = false;
		rep(i,N){
			if(now[i]==100)continue;
			bool F = true;
			rep(j,r.size()){
				if(r[j][i]==now[i]){
					F=false;
					break;
				}
			}
			if(F){
				f=true;
				now[i]++;
				break;
			}
		}
		if(!f)break;
	}
	
	if(l.size()==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3524
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct SCC{
  Int n;
  vector<vector<Int> > G,rG,T,C;
  vector<Int> vs,used,blg;
  SCC(){}
  SCC(Int n):n(n),G(n),rG(n),used(n),blg(n){}
  
  void add_edge(Int from,Int to){
    G[from].emplace_back(to);
    rG[to].emplace_back(from);
  }
  
  void dfs(Int v){
    used[v]=1;
    for(Int u:G[v])
      if(!used[u]) dfs(u);
    vs.emplace_back(v);
  }
  
  void rdfs(Int v,Int k){
    used[v]=1;
    blg[v]=k;
    C[k].emplace_back(v);
    for(Int u:rG[v])
      if(!used[u]) rdfs(u,k);
  }
  
  Int build(){
    for(Int v=0;v<n;v++)
      if(!used[v]) dfs(v);
    
    fill(used.begin(),used.end(),0);
    Int k=0;
    for(Int i=vs.size()-1;i>=0;i--){
      if(!used[vs[i]]){
        T.emplace_back();
        C.emplace_back();
        rdfs(vs[i],k++);
      }
    }
    for(Int v=0;v<n;v++)
      for(Int u:G[v])
        if(blg[v]!=blg[u])
          T[blg[v]].push_back(blg[u]);
    
    for(Int i=0;i<k;i++){
      sort(T[i].begin(),T[i].end());
      T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
    }
    return k;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int m,n;
  cin>>m>>n;
  
  struct Skill{
    vector<Int> s,t;
    vector<string> cond;
    Skill(Int k):s(k),t(k),cond(k){}
  };
  
  vector<Skill> vs;
  for(Int i=0;i<m;i++){
    Int k;
    cin>>k;
    vs.emplace_back(k);
    for(Int j=0;j<k;j++)
      cin>>vs[i].s[j]>>vs[i].cond[j]>>vs[i].t[j],vs[i].s[j]--;
  }
  
  auto check=
    [&](Int x,Int y)->Int{
      auto &vx=vs[x];
      auto &vy=vs[y];
      vector<Int> va(n,0);
      
      for(Int i=0;i<(Int)vx.s.size();i++){
        if(vx.cond[i]==">=")
          chmax(va[vx.s[i]],vx.t[i]);
      }
      
      for(Int i=0;i<(Int)vy.s.size();i++){
        if(vy.cond[i]=="<="){
          if(va[vy.s[i]]>vy.t[i]) return 1;
        }
      }
      
      return 0;
    };
  
  auto NG=[](){cout<<"No"<<endl;exit(0);};  
  for(Int i=0;i<m;i++) if(check(i,i)) NG();

  SCC scc(m);
  for(Int i=0;i<m;i++)
    for(Int j=0;j<m;j++)
      if(check(i,j)) scc.add_edge(j,i);
  
  if(scc.build()!=m) NG();
  
  cout<<"Yes"<<endl;
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4092
final_rank: 12

code_snippet: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

vector<vi> g;
bool ans = true;
vi used;
void dfs(int now,int t){
    rep(i,g[now].size()){
        if(g[now][i] == t)ans = false;
        if(used[g[now][i]])return;
        used[now]++;
        dfs(g[now][i],t);
    }
}

signed main(void) {
    int m,n;
    cin >> m >> n;
    vector<vp> v(m);
    bool c = true;
    rep(i,m){
        int k;
        cin >> k;
        vp in(n,pii(-1,-1));
        rep(j,k){
            int a,b;
            string s;
            cin >> a >> s >> b;
            a--;
            if(s == ">="){//first
                if(in[a].first == -1) in[a].first = b;
                else in[a].first = max(in[a].first, b);
            }else{//second
                if(in[a].second == -1) in[a].second = b;
                else in[a].second = min(in[a].second, b);
            }
        }
        rep(j,n){
            int l = in[j].first, r = in[j].second;
            if(l != -1 && r != -1 && l > r){
                c = false;
                break;
            }
        }
        v[i] = in;
    }

    if(c == false){
        cout << "No" << endl;
        return 0;
    }

    g = vector<vi>(m);
    rep(i,m)rep(j,m)if(i != j){// i -> j ?
        int c = 0;
        rep(k,n){
            if(v[j][k].second != -1 && v[i][k].first != -1 && v[j][k].second < v[i][k].first){
                if(c == 1) ans = false;
                else c = -1;
            }
            if(v[i][k].second != -1 && v[j][k].first != -1 && v[i][k].second < v[j][k].first){
                if(c == -1)ans = false;
                else c = 1;
            }
        }
        //cout << i << " " << j << " " << c << " " << ans << endl;
        if(c == 1)g[i].push_back(j);//,cout << i << " " << j << endl;
    }
    //グラフの閉路検出
    rep(i,m)if(ans){
        used = vi(m,0);
        used[i]++;
        dfs(i,i);
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3400
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;

struct Restrict{
    int v;
    int idx;
    int t;
    bool isLess;
};

bool l_to_r(Restrict lhs,Restrict rhs){
    return lhs.idx==rhs.idx &&
            lhs.isLess && !rhs.isLess  &&
            lhs.t<rhs.t;
}

using Graph=vector<vector<int>>;

bool isDAG(Graph &g){
    int n=g.size();
    vector<int> d(n);
    for(int i=0;i<n;i++)for(int j=0;j<g[i].size();j++) d[g[i][j]]++;
    queue<int> que;
    for(int i=0;i<n;i++) if(d[i]==0) que.push(i);
    int cnt=0;
    while(!que.empty()){
        int v=que.front(); que.pop();
        cnt++;
        for(int i=0;i<g[v].size();i++){
            d[g[v][i]]--;
            if(d[g[v][i]]==0){
                que.push(g[v][i]);
            }
        }
    }
    return cnt==n;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<Restrict> rvec;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int s,t;
            string cond;
            cin>>s>>cond>>t;
            s--;
            bool isLess=(cond=="<=");
            rvec.push_back(Restrict{i,s,t,isLess});
        }
    }
    Graph g(n);
    for(int i=0;i<rvec.size();i++){
        for(int j=0;j<rvec.size();j++){
            if(l_to_r(rvec[i],rvec[j])){
                g[rvec[i].v].push_back(rvec[j].v);
            }
        }
    }
    cout<<(isDAG(g) ? "Yes" : "No")<<endl;
    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3784
final_rank: 18

code_snippet: #include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int main() {
	vector<int> G[100];
	P need[100][100];
	int m, n; cin >> m >> n;
	rep(i, m) {
		rep(j, n) {
			need[i][j] = { -1,101 };
		}
	}
	int s; string o; int c; int K;
	rep(i, m) {
		cin >> K;
		rep(j, K) {
			cin >> s >> o >> c; s--;
			if (o == ">=") {
				need[i][s].first = max(need[i][s].first, c);
			}
			else {
				need[i][s].second = min(need[i][s].second, c);
			}
		}
	}
	int used[100][100] = {};
	rep(i, m) {
		Rep(j,i, m) {
			rep(k, n) {
				if (need[i][k].second < need[j][k].first&&!used[i][j]) {
					G[i].push_back(j); used[i][j] = 1;
				}
				if (need[j][k].second < need[i][k].first && !used[j][i]) {
					G[j].push_back(i); used[j][i] = 1;
				}
			}
		}
	}
	bool f = false;
	rep(i, m) {
		int cyc[100] = {};
		queue<int> q; q.push(i); cyc[i] = 1;
		while (!q.empty()) {
			int now = q.front(); q.pop();
			int len = G[now].size();
			rep(j, len) {
				int v = G[now][j];
				if (v == i)f = true;
				if (!cyc[v]) {
					cyc[v] = 1; q.push(v);
				}
			}
		}
	}
	if (f)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3392
final_rank: 6

code_snippet: #include <bits/stdc++.h>

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    const string GL = ">=";
    int n,m; cin >> m >> n;
    vector<vector<int> > g(m, vector<int>(n,0));
    vector<vector<int> > l(m, vector<int>(n,100));
    for(int i = 0; i < m; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int s,t; string c;
            cin >> s >> c >> t;
            s--;
            if(c == GL){
                g[i][s] = max(g[i][s], t);
            }
            else{
                l[i][s] = min(l[i][s], t);
            }
        }
    }
    vector<bool> isget(m, false);
    vector<int> skill(n, 0);
    for(int i = 0; i < m; i++){
        for(int j = 0; j < m+1; j++){
            if(j == m){
                cout << "No" << endl;
                return 0;
            }
            if(isget[j])continue;
            vector<int> st = skill;
            for(int k = 0; k < n; k++){
                if(st[k] < g[j][k])st[k] = g[j][k];
            }
            bool flag = true;
            for(int k = 0; k < m; k++){
                if(isget[k])continue;
                for(int p = 0; p < n; p++){
                    if(st[p] > l[k][p]){
                        flag = false;
                        k = m;
                        break;
                    }
                }
            }
            if(flag){
                swap(skill, st);
                isget[j] = true;
                break;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3280
final_rank: 2

code_snippet: #include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <string>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;

// 移動元と行先と辺のコストを記録する構造体
template <typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int s, T d) : to(s), cost(d) {}
    Edge(int f, int s, T d) : from(f), to(s), cost(d) {}

    bool operator<(const Edge &e) const {
        return cost < e.cost;
    }
    bool operator>(const Edge &e) const {
        return cost > e.cost;
    }
};

template <typename T>
using Graph = vector< vector< Edge<T> > >;

template <typename T>
vector<int> tpsort_Kahn(const vector< vector< Edge<T> > > &g) {
    const int V = g.size();
    vector<int> indeg(V, 0);
    stack<int> S;

    rep(i,0,V) rep(j,0,g[i].size())
        indeg[ g[i][j].to ]++;
    rep(i,0,V) if(indeg[i] == 0) S.push(i);

    vector<int> ans;
    while(S.size() > 0) {
        int u = S.top(); S.pop();
        ans.push_back(u);
        rep(i,0,g[u].size()) {
            indeg[ g[u][i].to ]--;
            if(indeg[ g[u][i].to ] ==  0)
                S.push( g[u][i].to );
        }
    }
    return ans;
}

const int INF = 1 << 28;
int lb[110][110], ub[110][110];

int main() {
    int M, N; cin >> M >> N;
    for(int i=0; i<M; i++) {
        fill(lb[i], lb[i] + N,  -1);
        fill(ub[i], ub[i] + N, INF);
    }

    Graph<int> G(M);
    bool ok = true;
    for(int i=0; i<M; i++) {
        int K; cin >> K;
        for(int k=0; k<K; k++) {
            int s, t;
            string cond;
            cin >> s >> cond >> t; s--;
            if(cond == "<=") ub[i][s] = min(ub[i][s], t);
            if(cond == ">=") lb[i][s] = max(lb[i][s], t);
        }
        for(int k=0; k<N; k++) {
            if(lb[i][k] > ub[i][k]) ok = false;
        }
    }

    for(int i=0; i<M; i++) {
        for(int j=0; j<M; j++) {
            if(i == j) continue;
            for(int k=0; k<N; k++) {
                // i より j の方が後でなければならない条件
                if(ub[i][k] == INF || lb[j][k] == -1) continue;
                if(ub[i][k] < lb[j][k]) {
                    G[i].push_back(Edge<int>(j, 1));
                }
            }
        }
    }

    if(tpsort_Kahn(G).size() != M) ok = false;
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 5008
final_rank: 15

code_snippet: #include<bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)

typedef struct Cond{
  int kind;
  int arrow;
  int bound;
}cond;

bool sr(const cond& l, const cond& r){
  return l.kind==r.kind ? l.arrow < r.arrow : l.kind < r.kind;
}

class Graph{
public:
  int v;
  vector<int> visited,visiting;
  vector<int> e[100];
  Graph(int m){
    v = m;
    visited = vector<int>(v);
    visiting = vector<int>(v);
  }
  void addEdge(int e1,int e2){
    if (find(e[e1].begin(),e[e1].end(),e2)==e[e1].end()){
      e[e1].push_back(e2);
    }
  }
  int dfs(int vv){
    int ret = 0;
    visited[vv] = 1;
    visiting[vv] = 1;
    rep(i,e[vv].size()){
      if(!visited[e[vv][i]]){
        ret += dfs(e[vv][i]);
      } else if (visiting[e[vv][i]]==1){
        return 1;
      }
    }
    visiting[vv] = 0;
    return ret;
  }

  int isDAG(){
    rep(i,v){
      int m = dfs(i);
      if (m>0){
        return 0;
      }
    }
    return 1;
  }

};


int main(){

  int m,n;
  cin >> m >> n;
  vector<int> k(m);
  vector<cond> conditions[100];
  pair<int,int> sections[100][100];

  rep(i,m){
    cin >> k[i];
    conditions[i] = vector<cond>(k[i]);
    rep(j,k[i]){
      string c;
      cin >> conditions[i][j].kind >> c >> conditions[i][j].bound;
      conditions[i][j].kind--;
      if (c==">="){
        conditions[i][j].arrow = 0;
      } else {
        conditions[i][j].arrow = 1;
      }
    }
    sort(conditions[i].begin(),conditions[i].end(),sr);
    //commandの条件内で矛盾を探す
    rep(j,100){sections[i][j].first=0;sections[i][j].second=101;}
    rep(j,conditions[i].size()){
      int k = conditions[i][j].kind;
      if (conditions[i][j].arrow == 0){
        sections[i][k].first = max(sections[i][k].first,conditions[i][j].bound);
      } else {
        sections[i][k].second = min(sections[i][k].second,conditions[i][j].bound);
      }
    }
    rep(j,n){
      if(sections[i][j].first>sections[i][j].second){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  //sections[i][j]: i番目のcommand,j番目のskillポイントがfirst以上second以下
  //skillポイントを固定して条件を見ていって，区間に交わりがない場合は小→大へ辺を張る
  Graph g(m);
  rep(skill,n){
    rep(com1,m){
      rep(com2,m){
        if (com1!=com2){
          int com1l = sections[com1][skill].first;
          int com1r = sections[com1][skill].second;
          int com2l = sections[com2][skill].first;
          int com2r = sections[com2][skill].second;
          if (com2r < com1l){
            g.addEdge(com2,com1);
          } else if (com1r < com2l){
            g.addEdge(com1,com2);
          }
        }
      }
    }
  }
  //閉路判定
  int result = g.isDAG();
  if (result == 1){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3396
final_rank: 7

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int m,n;
    cin >> m >> n;
    vector<vector<vector<int> > > cond(m, vector<vector<int> >(n+1, vector<int>(2)));
    for(int i=0; i<m; i++){
        for(int j=1; j<=n; j++){
            cond[i][j][0] = inf;
            cond[i][j][1] = -1;
        }
    }
    
    for(int i=0; i<m; i++){
        int k;
        cin >> k;
        for(int j=0; j<k; j++){
            int s,t;
            string c;
            cin >> s >> c >> t;
            int sl = (c=="<=")? 0: 1;
            if(sl==0){
                cond[i][s][sl] = min(cond[i][s][sl], t);
            }else{
                cond[i][s][sl] = max(cond[i][s][sl], t);
            }
        }
    }
    for(int i=0; i<m; i++){
        for(int j=1; j<=n; j++){
            if(cond[i][j][0] < cond[i][j][1]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    vector<vector<int> > adj(m, vector<int>(m, inf));
    for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
            for(int k=1; k<=n; k++){
                if(cond[i][k][0] < cond[j][k][1]){
                    adj[i][j] = 0;
                    break;
                }
            }
        }
    }

	for(int k=0; k<m; k++){
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
			}
		}
	}
	
	bool flag = true;
	for(int i=0; i<m; i++){
		for(int j=i+1; j<m; j++){
			if(adj[i][j]==0 && adj[j][i]==0){
				flag = false;
				break;
			}
		}
	}
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3788
final_rank: 9

code_snippet: #include<iostream>
#include<vector>
#define r(i,n)for(int i=0;i<n;i++)
using namespace std;
#define F first
#define S second
typedef pair<int,int>P;
int n,m,x,y,K,a[102][102],flag,amin[102][102],amax[102][102];
string s;
vector<P>v1[102],v2[102];
bool ch(){
  r(i,m){
    r(j,v1[i].size()){
      r(k,v2[i].size()){
	if(v1[i][j].F==v2[i][k].F&&v1[i][j].S<v2[i][k].S) return 1;
      }
    }
  }
  return 0;
}
void make_Graph(){
  r(i,102)r(j,102)amax[i][j]=1e8;
  r(i,m){
    r(j,v1[i].size())amax[i][v1[i][j].F]=min(amax[i][v1[i][j].F],v1[i][j].S);
    r(j,v2[i].size())amin[i][v2[i][j].F]=max(amin[i][v2[i][j].F],v2[i][j].S);
    r(j,102)amin[i][j]=min(amin[i][j],amax[i][j]);
  }
  r(i,m)r(j,m)r(k,102)if(amax[i][k]<amin[j][k])a[i][j]=-1;
}
int main(){
  cin>>m>>n;
  r(i,m){
    cin>>K;
    r(j,K){
      cin>>x>>s>>y;
      if(s=="<=")v1[i].push_back(P(x,y));
      else v2[i].push_back(P(x,y));
    }
  }
  if(ch())cout<<"No"<<endl;
  else{
    r(i,102)r(j,102)a[i][j]=(i==j?0:1e8);
    make_Graph();
    n++;
    r(o,m)r(i,m)r(j,m)a[i][j]=min(a[i][j],a[i][o]+a[o][j]);
    r(i,102)if(a[i][i]<0)flag++;
    cout<<(flag?"No":"Yes")<<endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3384
final_rank: 5

code_snippet: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

//??????A[a,b]??¨??????B[c,d]?????¢???
int intervalState(int a, int b, int c, int d){
    if(a < c && b < c) return 0;            //A < B
    else if(a > d && b > d) return 1;       //A > B
    else if(a <= c && d <= b) return 2;     //A -> B
    else if(c < a && b < d) return 3;       //B -> A
    else if(a <= c && b < d) return 4;      //A <= B
    else if(c < a && d <= b) return 5;      //A >= B
    return -1;
}

//Give input directly to vector<pair<int, int>> in
vector<pair<int, int>> JoinInterval(vector<pair<int,int>> in){
    vector<pair<int, int>> v;
    rep(i,in.size()) in[i].second *= -1;
    sort(all(in));
    rep(i,in.size()) in[i].second *= -1;

    rep(i,in.size()){
        if(v.empty()) v.emplace_back(in[i]);
        else{
            pair<int, int> &u = v.back();
            int tmp = intervalState(in[i].first,in[i].second,u.first,u.second);
            switch (tmp){
                case 0:
                case 1:
                    v.emplace_back(in[i]);
                    break;
                case 2:
                    u.first = in[i].first;
                    u.second = in[i].second;
                    break;
                case 3:
                    break;
                case 4:
                case 5:
                    u.first = max(u.first, in[i].first);
                    u.second = min(u.second, in[i].second);
                    break;
                case -1:
                    assert(0);
            }
        }
    }
    sort(all(v));
    return v;
}

int main(){
    int m,n;
    vector<pair<int,int>> v[105]; //v[i] := i??????????????????????????¶
    rep(i,105) v[i] = vector<pair<int,int>>(105);
    rep(i,105) rep(j,105) v[i][j] = make_pair(0,105);

    cin >> m >> n;
    rep(i,m){
        int k;
        cin >> k;
        map<int,vector<pair<int, int>>> m;
        rep(j,k){
            int num, point;
            string s;
            cin >> num >> s >> point;
            num--;

            pair<int, int> p;
            if(s[0] == '<') p = make_pair(0,point);
            else p = make_pair(point,105);
            m[num].emplace_back(p);
        }
        for(auto it : m){
            vector<pair<int, int>> in = JoinInterval(it.second);
            if(in.size() >= 2){
                cout << "No" << endl;
                return 0;
            }
            v[i][it.first] = in[0];
        }
    }

    auto canTake = [](vector<pair<int, int>> a, vector<pair<int, int>> b){
        rep(i,105) if(b[i].second < a[i].first) return 0;
        return 1;
    };

    bool used[105] = {0};
    rep(_,m){
        rep(i,m){
            if(used[i]) continue;
            bool f = true;
            //i??????????????????????¬??????¨?????¨?????????
            rep(j,m){
                if(used[j] || i == j) continue;
                if(not canTake(v[i],v[j])){
                    f = false;
                    break;
                }
            }
            used[i] = f;
        }
    }
    //rep(i,m) show(used[i])

    auto check = [](bool used[105], int m){
        rep(i,m) if(used[i] == 0) return 0;
        return 1;
    };
    cout << (check(used,m) ? "Yes" : "No") << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3268
final_rank: 1

code_snippet: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

//??????A[a,b]??¨??????B[c,d]?????¢???
int intervalState(int a, int b, int c, int d){
    if(a < c && b < c) return 0;            //A < B
    else if(a > d && b > d) return 1;       //A > B
    else if(a <= c && d <= b) return 2;     //A -> B
    else if(c < a && b < d) return 3;       //B -> A
    else if(a <= c && b < d) return 4;      //A <= B
    else if(c < a && d <= b) return 5;      //A >= B
    return -1;
}

//Give input directly to vector<pair<int, int>> in
vector<pair<int, int>> JoinInterval(vector<pair<int,int>> in){
    vector<pair<int, int>> v;
    rep(i,in.size()) in[i].second *= -1;
    sort(all(in));
    rep(i,in.size()) in[i].second *= -1;

    rep(i,in.size()){
        if(v.empty()) v.emplace_back(in[i]);
        else{
            pair<int, int> &u = v.back();
            int tmp = intervalState(in[i].first,in[i].second,u.first,u.second);
            switch (tmp){
                case 0:
                case 1:
                    v.emplace_back(in[i]);
                    break;
                case 2:
                    u.first = in[i].first;
                    u.second = in[i].second;
                    break;
                case 3:
                    break;
                case 4:
                case 5:
                    u.first = max(u.first, in[i].first);
                    u.second = min(u.second, in[i].second);
                    break;
                case -1:
                    assert(0);
            }
        }
    }
    sort(all(v));
    return v;
}

int isBigger(vector<pair<int, int>> a, vector<pair<int, int>> b){
    bool ret[6] = {0};
    rep(i,101){
        int tmp = intervalState(a[i].first,a[i].second,b[i].first,b[i].second);
        assert(tmp <= 5);
        ret[tmp] = true;
    }
    if(ret[0] && ret[1]) return -1;
    else if(ret[0]) return 0;
    else if(ret[1]) return 1;
    else return 2;
}

int main(){
    int m,n;
    vector<pair<int,int>> v[105]; //v[i] := i??????????????????????????¶
    rep(i,105) v[i] = vector<pair<int,int>>(105);
    rep(i,105) rep(j,105) v[i][j] = make_pair(0,105);

    cin >> m >> n;
    rep(i,m){
        int k;
        cin >> k;
        map<int,vector<pair<int, int>>> m;
        rep(j,k){
            int num, point;
            string s;
            cin >> num >> s >> point;
            num--;

            pair<int, int> p;
            if(s[0] == '<') p = make_pair(0,point);
            else p = make_pair(point,105);
            m[num].emplace_back(p);
        }
        for(auto it : m){
            vector<pair<int, int>> in = JoinInterval(it.second);
            if(in.size() >= 2){
                cout << "No" << endl;
                return 0;
            }
            v[i][it.first] = in[0];
        }
    }

    rep(i,n){
    //rep(i,m){ rep(j,n){ cout << v[i][j].first << ' ' << v[i][j].second << endl; } cout << endl; } cout << endl;
        rep(j,n- 1){
            switch (isBigger(v[j],v[j + 1])) {
                case 0:
                    //g[j][j + 1] = 1;
                    break;
                case 1:
                    swap(v[j],v[j + 1]);
                    //g[j + 1][j] = 1;
                    break;
                case 2:
                    break;
                case -1:
                    cout << "No" << endl;
                    return 0;

                default:
                    assert(1);
            }
        }
    }

    int point[105] = {0};
    rep(i,n){
        rep(j,m){
            if(point[j] >= v[i][j].first && point[j] <= v[i][j].second) continue;
            if(point[j] < v[i][j].first){
                point[j] = v[i][j].first;
            }else if(point[j] > v[i][j].first){
                cout << "No" << endl;
                return 0;
            }
            //show(point[j])
        }
        //cout << endl;
    }
    cout << "Yes" << endl;
}
accuracy: 0.6039603960396039
time_ms: 10
memory_kb: 3268
final_rank: 19

code_snippet: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

bool f = 1, e[100][100];
int n;

void dfs(int now, int par, VI &visit){
    if (visit[now]){
        if (now == par) f = 0;
        return;
    }
    visit[now] = 1;
    REP(i,n){
        if (e[now][i]) dfs(i, par, visit);
    }
}

int main() {
    int m;
    cin >> n >> m;
    VVI h(n, VI(m, 1000)), l(n, VI(m));
    REP(i,n){
        int k;
        cin >> k;
        while (k--){
            int j, x;
            string s;
            cin >> j >> s >> x;
            if (s == ">=") l[i][j-1] = max(l[i][j-1], x);
            else h[i][j-1] = min(h[i][j-1], x);
        }
    }
    REP(i,n) REP(j,m) if (l[i][j] > h[i][j]) f = 0;
    REP(i,n) REP(j,n){
        bool g = 0;
        REP(k,m) if (l[i][k] > h[j][k]) g = 1;
        e[i][j] = g;
    }

    REP(i,n){
        VI visit(n);
        dfs(i, i, visit);
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3292
final_rank: 3

code_snippet: #include<bits/stdc++.h>
using namespace std;

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int M,N;
int S[100][100];
int T[100][100];

const int INF=1001001001;
int D[100][100];
signed main(){
    cin>>M>>N;
    rep(i,M)rep(j,N)S[i][j]=0,T[i][j]=100;
    rep(i,M){
        int K;cin>>K;
        while(K--){
            int s,t;
            string c;
            cin>>s>>c>>t;s--;
            if(c=="<=")chmin(T[i][s],t);
            else chmax(S[i][s],t);
        }
    }
    rep(i,M)rep(j,N)if(S[i][j]>T[i][j]){
        cout<<"No"<<endl;
        return 0;
    }

    fill_n(*D,100*100,INF);
    rep(i,M)D[i][i]=0;
    rep(i,M)rep(j,M)if(i!=j){
        bool flag=false;
        rep(k,N)if(T[i][k]<S[j][k])flag=true;
        if(flag)D[i][j]=0;
    }

    rep(k,M)rep(i,M)rep(j,M)chmin(D[i][j],D[i][k]+D[k][j]);

    rep(i,M)rep(j,M)if(i!=j&&D[i][j]!=INF&&D[j][i]!=INF){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3348
final_rank: 4