Cod sursa(job #3153780)

Utilizator PsyDuck1914Feraru Rares-Serban PsyDuck1914 Data 1 octombrie 2023 11:30:32
Problema Text Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.81 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f ("text.in");
ofstream g ("text.out");

string s;
bitset<100001> c;
int cnt;


int main()
{
    long long size = 0;
    string aux;
    s.push_back('-');
    while(f >> aux){
        s += aux;
        s += ' ';
    }
    s.push_back('-');

   for(int i=0; i<s.size()-1; i++)
        if(!isalpha(s[i]))
            c[i] = 1;
    
    int last = 0;
    
    for(int i=0; i<s.size(); i++)
        if(c[i] == 0)
            size++;
    
    for(int i=s.size()-2; i>=0; i--)
        if(c[i] == 1)
            last = i;
    
    
    for(int i=last+1; i<s.size()-1; i++){
        if(c[i] == 1){
            if(i - last > 1)
                cnt ++;
            last = i;
        }
    }
    
    if(cnt == 0) 
        g << 0;
    else
        g << size/cnt;

    

    return 0;
}