Pagini recente » Cod sursa (job #2517888) | Cod sursa (job #1957960) | Cod sursa (job #136060) | Cod sursa (job #1899330) | Cod sursa (job #2965921)
#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;
}