Submission #1120751

#TimeUsernameProblemLanguageResultExecution timeMemory
1120751vjudge1KOVANICE (COI15_kovanice)C++17
50 / 100
635 ms5160 KiB
#include <bits/stdc++.h>
using namespace std;
# define int long long

void solve()
{
  vector < pair < int , int > > comp;
  int n, m, v;
  cin >> n >> m >> v;
  vector < int > chk(m, 0);
  for(int i = 0; i < v; i++)
  {
    int a, b;
    char c;
    cin >> a >> c >> b;
    if(c == '=')
      comp.push_back({a, b});
    if(c == '>')
    {
      chk[a] = 2;
      chk[b] = 1;
    }
    else if(c == '<')
    {
      chk[a] = 1;
      chk[b] = 2;
    }
  }
  for(int bit = 0; bit < 100; bit++)
  {
    for(int i = 0; i < comp.size(); i++)
    {
      if(chk[comp[i].first] == 0)
        chk[comp[i].first] = chk[comp[i].second];
      else
        chk[comp[i].second] = chk[comp[i].first];
    }
  }
  for(int i = 1; i <= m; i++)
  {
    if(chk[i] == 0)
      cout << '?' << endl;
    else
    {
      cout << "K" << chk[i] << endl;
    }
  }
}

signed main()
{
  int tt = 1;
  // cin >> tt;
  while(tt--)
    solve();
}

Compilation message (stderr)

kovanice.cpp: In function 'void solve()':
kovanice.cpp:31:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0; i < comp.size(); i++)
      |                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...