ojudge

A self-hosted competitive programming site written in OCaml
git clone git://git.laack.co/ojudge.git
Log | Files | Refs | README

failing.cpp (631B)


      1 #include <iostream>
      2 
      3 using namespace std;
      4 
      5 int countMatches(string base, string matcher) {
      6     int res = 0;
      7     for(int i = 0; i <= base.size() - matcher.size(); ++i) {
      8         if(base.substr(i,matcher.size()) == matcher) {
      9             res += 1;
     10         }
     11     }
     12     return res;
     13 }
     14 
     15 int main() {
     16 
     17     string a,b,c,d = "";
     18 
     19     cin >> a;
     20     cin >> b;
     21     cin >> c;
     22     cin >> d;
     23     int mt = 0;
     24 
     25     if(d.size() <= a.size()) {
     26         mt += countMatches(a,d);
     27     }
     28     if(d.size() <= b.size()) {
     29         mt += countMatches(b,d);
     30     }
     31     if(d.size() <= c.size()) {
     32         mt += countMatches(c,d);
     33     }
     34 
     35     cout << mt << endl;
     36 }