Cod sursa(job #2855388)

Utilizator leo05Leonardo Mosutan leo05 Data 22 februarie 2022 13:30:17
Problema Abc2 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.13 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;

int main()
{
    ifstream in("abc2.in");
    ofstream out("abc2.out");
    
    int ok = 0, n = 0, k = 0, bn = 0;
    char cuvant[10000000], cuvant1[50000][50000], cuv[50000], cuvaux[50000], cuvant2[50000][50000];
    in >> cuvant;

    while(in >> cuv){
        strcpy(cuvant1[n++], cuv);
    }
    
    for(int i = 0; i < n-1; i++){
        ok = 0;
        for(int j = i+1; j < n; j++){
            if(cuvant1[i] == cuvant1[j])ok++;
        }
        if(!ok){
            strcpy(cuvant2[k++], cuvant1[i]);
        }
    }

        
    for(int i = 0; cuvant[i] != NULL; i++){
        for(int j = 0; j < k; j++)
            if(strstr(cuvant+(strlen(cuvant2[1]))+i, cuvant2[j]))bn++;
    }
    
    out << bn;
}