Skip to content

Instantly share code, notes, and snippets.

@lazycipher
Created June 7, 2019 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazycipher/be9df4b24a059afa8ed8e9dc9b2b28c3 to your computer and use it in GitHub Desktop.
Save lazycipher/be9df4b24a059afa8ed8e9dc9b2b28c3 to your computer and use it in GitHub Desktop.
Codeforces 96A Football Solution C++
#include<iostream>
using namespace std;
int main(){
string s1;
cin>>s1;
int condition = 1;
for(int i=1; i<=s1.length(); i++){
if(s1[i] == s1[i-1]){
condition++;
if(condition==7){
cout<<"YES"<<endl;
return 0;
}
}else{
condition=1;
}
}
cout<<"NO"<<endl;
return 0;
}
@dakshg51
Copy link

#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
if(s.find("0000000")<100||s.find("1111111")<100){
cout<<"YES";
return 0;
}
cout<<"NO";
return 0;
}
//is this a good code ??

@KishanMishra1
Copy link

#Simple LOGIC
q = "0000000"
p = "1111111"
k = input()
if q in k or p in k:
print("YES")
else:
print("NO")

@L0rd-AK
Copy link

L0rd-AK commented Jan 3, 2022

your code is wrong
you didn't even declare header file

#include
#include
using namespace std;

int main()
{
int count=0;
string s;
cin>>s;
for(int i=0;i<s.length();i++)
{
if(s[i]==s[i+1])
{
count++;
if(count==6)
{
cout<<"YES"<<endl;
return 0;
}
}
else
{
count=0;
}
}
cout<<"NO"<<endl;
return 0;
}

@KishanMishra1
Copy link

i dont need any header though its python-magic ..

@ImErdis
Copy link

ImErdis commented Feb 17, 2022

no magics for python mate

@A-N-R-I
Copy link

A-N-R-I commented Oct 22, 2022

i <= s1.length()

Isn't that a potential error? As s[i] would be invalid if that ever happens? Did you test this code?

@zihadul10101
Copy link

zihadul10101 commented Nov 10, 2023

#include <bits/stdc++.h>
using namespace std;

int main()
{
string s;
cin>>s;
int ans=0;

for(int i=0;i<s.size();i++){
    int count=0;
    if(s[i]=='0'){
       while(s[i]=='0' && i<s.size()){
           count++;
           i++;
       }
    }else{
       if(s[i]=='1'){
       while(s[i]=='1' && i<s.size()){
           count++;
           i++;
       }  
    }
    i--; 
    }
   if(count>=7){
        ans=1;
    }
}

if(ans==1){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
return 0;
}

@PLASTA0728
Copy link

Hi guys this is my code and seems to have a different logic compared to yours. However, when testing, I don't understand why my code is wrong at test 42. Can you help me figure out which part of the code is wrong, thanks so much!

// https://codeforces.com/problemset/problem/96/A
#include <iostream>
#include <string>
using namespace std;

int main(){
    string str;
    cin >> str;
    int l = str.length();
    int sum[l+1];
    sum[0] = 0;
    for (int i = 1; i <= l; i++){
        sum[i] = sum[i-1] + (str[i-1] - '0');
    }
    bool found = false;
    for (int i = 1; i <= l-7; i++){
        if (sum[i+7]-sum[i] == 7 || sum[i+7]-sum[i] == 0){
            found = true;
            break;
        }
    }
    if (found){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment