Submission #846245

# Submission time Handle Problem Language Result Execution time Memory
846245 2023-09-07T12:53:08 Z vjudge1 KOVANICE (COI15_kovanice) C++17
0 / 100
225 ms 66360 KB
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define int long long
using namespace std;

const int inf = 2e18 + 5;
const int N = 3e5 + 5;
const int mod = 1e9 + 7;

vector<int> par(N);
vector<int> adj[N], radj[N];

int find(int a){
 if(a == par[a]) return a;
 return par[a] = find(par[a]);
}

void merge(int a, int b){
  a = find(a), b = find(b);
  par[a] = b;
}


int32_t main(){
  //freopen("in.txt","r", stdin);
  int n, m, v;
  cin>>n>>m>>v;
  for(int i = 1; i <= m; i++) par[i] = i;

  vector<array<int, 2> > type;
  for(int i = 0; i < v; i++){
     string s;
     cin>>s;

     if(s[1] == '='){
        merge(s[0] - '0', s[2] - '0');
     }
     else{
        if(s[1] == '>') swap(s[0], s[2]);
        type.pb({s[0] - '0', s[2] - '0'});
     }
  }

  map<int, int> big, tiny;
  for(int i = 0; i < type.size(); i++){
    int x = find(type[i][0]), y = find(type[i][1]);
    adj[x].pb(y);
    radj[y].pb(x);
    big[y] = 1;
    tiny[x] = 1;
  }

  for(int i = 1; i <= m; i++){
    int x = find(i);
    if(big[x]) cout<<"K2"<<endl;
    else if(tiny[x]) cout<<"K1"<<endl;
    else cout<<"?"<<endl;
  }
  return 0;
}

Compilation message

kovanice.cpp: In function 'int32_t main()':
kovanice.cpp:46:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for(int i = 0; i < type.size(); i++){
      |                  ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 16984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 45764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 21184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 225 ms 66360 KB Output isn't correct
2 Halted 0 ms 0 KB -