-
Notifications
You must be signed in to change notification settings - Fork 0
/
1st.cpp
52 lines (52 loc) · 1.05 KB
/
1st.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream in;
ofstream out;
in.open("A-large.in");
out.open("output.txt");
int n,a=1,count=0;
string s;
in>>n;
while(n--)
{
count=0;
in>>s;
int k;
in>>k;
int l=s.length();
for(int i=0;i<l-k+1;i++)
{
int temp=k;
if(s[i]=='+')
continue;
else
{
count++;
int m=i;
while(temp--)
{
if(s[m]=='+')
s[m++]='-';
else
s[m++]='+';
}
}
}
int j=0;
for(int i=l-k;i<l;i++)
{
if(s[i]=='-')
{
out<<"Case #"<<a<<":"<<" IMPOSSIBLE"<<endl;
j=1;
a++;
break;
}
}
if(j==0){
out<<"Case #"<<a++<<":"<<" "<<count<<endl;
}
}}