How should I tackle this problem

I was given a problem and I can't seem figure out how I should be tackling the Problem I would appreciate If you all could steer me on to the right track.

There are 2 pirates and they n(or just 4k) number of gold and silver coins in a line. The number of gold(as in 2k) and silver(as in 2k) coins is equal and there are both even numbers. The pirates will put them in a line and cut them equally. But the pirate are lazy so you must find the minimum number of cuts to do .
input explanation: the first number will be the number of silver and gold coins combined. which there will be equal amount of. Them on the next line there would be the line of 1 and 0 to represent the coins with spaces to separate them.
example input:
8
1 0 1 0 1 0 1 0
output:
1
4 5
explanation of output: the first number will be the amount of cuts you would do. Then the next line would be the coordinates of the cut for example between the 4th and 5 coins

I already made something to intake all the coin and the numbers but I can't figure out what to do with them. Could you steer me in the right direction. I was thinking of finding the biggest palendrom number but that doesnt work on 101010

1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;
int main() {
   int n;
   cin>>n;
   int numbers[n];
   for(int i=0;i<n;i++){
   	cin>>numbers[n];
   }
   }
Last edited on
Give an example that requires more than one cut.
Show the input and the output.
@dutch input:
6
1 1 1 0 0 0
Output
3
2 3 3 4 4 5
Explanation
1 1| 1 | 0 |0 0 this cut makes it so that it between 2 and 3, 3 and 4, 4 and 5 to make it equally work the minimum amount of cut
Sorry for bad English
That input doesn't correspond to your question. There is no way that 6=4k. Nor are individual numbers of gold and silver coins even.
Oh no my teacher told me it's just another way of implying that their both even numbers
There is also
Input:
12
1 0 0 0 1 1 0 1 0 1 0 1
Output
3
3 4 6 7 9 10
Last edited on
Input:
12
1 0 0 0 1 1 0 1 0 1 0 1
Output
3
3 4 6 7 9 10 

Why isn't the output just 1 cut:
1
6 7


Where on earth are you getting your sample outputs from?
Last edited on
¿how big is n?


1
2
3
   for(int i=0;i<n;i++){
   	cin>>numbers[n];
   }
that's wrong
at least test what you wrote
I just made the 12 one up
Value of n can be high as possible so i would like to give the number the same amount of arrays
I just made the 12 one up


Well, you've now given us two sample outputs which are both wrong. Please give us some correct ones.

I've yet to come up with any examples that need more than 2 cuts. Tentatively, I think that's what happens. Everything is either of the form:
1 cut:
A.....A | B.....B
or
2 cuts:
A...A | B.....B | A...A

If the first doesn't give balanced coins, then try all the rotations to get the second.
Last edited on
@lastchance thank you so much that example of
1 cut:
A.....A | B.....B
or
2 cuts:
A...A | B.....B | A...A

just made everythung click thank you
Last edited on
Topic archived. No new replies allowed.