Cod sursa(job #2965921)

Utilizator iraresmihaiiordache rares mihai iraresmihai Data 16 ianuarie 2023 16:22:15
Problema A+B Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.31 kb
#include <iostream>
#include <vector>

#define NR_LETTERS 26
using namespace std;

FILE *fin, *fout;

struct node{
  bool isImportant;
  int parent;
  vector <int> costs;
  int nextLetterId[NR_LETTERS];
};

struct nodeForWords{
  int parent, distFromParent;

};

node tree[MAXN];
int nrNodes;

void readWord() {
  char ch;
  int posInTree;

  ch = fgetc(fin);
  posInTree = 0;
  while ( 'a' <= ch && ch <= 'z' ) {
    if ( !tree[posInTree].nextLetterId[ch - 'a'] ) {
      posInTree = tree[posInTree].nextLetterId[ch - 'a'];s
    } else {
      tree[posInTree].nextLetterId[ch - 'a'] = nrNodes;
      nrNodes++;
      posInTree = tree[posInTree].nextLetterId[ch - 'a'];
    }
  }
  tree[posInTree].isImportant = true;
}

void dfs(int lastImportantNode, int pos, int distFromLastImportantWord) {
  if ( tree[pos].isImportant ) {
    tree[pos].parent = lastImportantNode;
    lastImportantNode = pos;
    distFromLastImportantWord = 0;
  }
  distFromLastImportantWord++;

  for ( i = 0; i < NR_LETTERS; i++ ) {
    if ( tree[pos].nextLetterId[i] ) {
      dfs(lastImportantNode, tree[pos].nextLetterId[i], distFromLastImportantWord);
    }
  }
}

int main() {
  fin = fopen("cli.in", "r");
  fout = fopen("cli.out", "w");

  int n, k, i;
  char ch;

  fscanf(fin, "%d%d", &n, &k);

  nrNodes = 0;
  for ( i = 0; i < n; i++ ) {

  }
  return 0;
}