-
-
Save lazycipher/be9df4b24a059afa8ed8e9dc9b2b28c3 to your computer and use it in GitHub Desktop.
#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; | |
} |
#Simple LOGIC
q = "0000000"
p = "1111111"
k = input()
if q in k or p in k:
print("YES")
else:
print("NO")
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;
}
i dont need any header though its python-magic ..
no magics for python mate
i <= s1.length()
Isn't that a potential error? As s[i] would be invalid if that ever happens? Did you test this code?
#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;
}
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;
}
#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 ??