Submission #743637

# Submission time Handle Problem Language Result Execution time Memory
743637 2023-05-17T14:58:58 Z Trisanu_Das KOVANICE (COI15_kovanice) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int long long

int n, m, v;
vector<pair<int, int> > edges;
vector<int> adj[1000005];
int par[1000005];

void dfs(int u, int p){
    if(par[u]) return;
    par[u] = p;
    for(int v : adj[u]) dfs(v, u);
}

vector< int > D[1000005], R[1000005]; int d[1000005], r[1000005];

int dfs_main(int u, vector< int > *D, int *d) {
  if (d[u] != 0) return d[u];
  for (int j : D[u]) d[u] = max(d[u], dfs_main(j, D, d));
  return ++d[u];
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> m >> v;
    while(v--){
        int a, b, char c; cin >> a >> c >> b;
        if(c == '<') edges.push_back({a, b});
        else{
            adj[a].push_back(b); adj[b].push_back(a);
        }
    }
    for(int i = 1; i <= m; i++) dfs(i, i);
    for (auto e : E) {
        D[com[e.first]].push_back(com[e.second]);
        R[com[e.second]].push_back(com[e.first]);
    }
    for(int i = 1; i < m + 1; i++) dfs_main(par[i], D, d);
    for(int i = 1; i < m + 1; i++) dfs_main(par[i], R, r);
    for(int i = 1; i < m + 1; i++){
        if(d[par[i]] + r[par[i]] - 1 == n) cout << 'K' << r[par[i]] << '\n';
        else cout << "?\n";
    }
}

Compilation message

kovanice.cpp: In function 'int main()':
kovanice.cpp:32:19: error: expected unqualified-id before 'char'
   32 |         int a, b, char c; cin >> a >> c >> b;
      |                   ^~~~
kovanice.cpp:32:39: error: 'c' was not declared in this scope
   32 |         int a, b, char c; cin >> a >> c >> b;
      |                                       ^
kovanice.cpp:39:19: error: 'E' was not declared in this scope
   39 |     for (auto e : E) {
      |                   ^
kovanice.cpp:40:11: error: 'com' was not declared in this scope; did you mean 'cos'?
   40 |         D[com[e.first]].push_back(com[e.second]);
      |           ^~~
      |           cos