CLEANUP - Editorial

i have tried all test cases and all possible cases for my solution still getting wrong answer fir this.dont know why…my solution link is:-https://www.codechef.com/viewsolution/14310780

If anyone finds where the error is then please help me…

so many people getting WA despite being a simple problem and what it seems to be a correct solution. Something is fishy here

can anyone tell why my code gives runtime error sigsegv
#include
using namespace std;

int main()
{
int t;
cin>>t;
while(t–){
int n,m;
cin>>n>>m;
int a[n+1]={0};
for(int i=0;i<m;i++){
int x;
cin>>x;
a[x] = 1;
}
int c=0,f=0;
int chef[n]={0},ass[n]={0};
for(int i=1,j=0,k=0;i<n+1;i++){
if(a[i]==0&&c==0){
chef[j]=i;
j++;
c=1;
f=0;
}
else if(a[i]==0&&f==0){
ass[k]=i;
k++;
f=1;
c=0;
}
}
for(int i=0;chef[i]!=0;i++)cout<<chef[i]<<" “;
cout<<endl;
for(int i=0;ass[i]!=0;i++)cout<<ass[i]<<” ";
cout<<endl;
}
return 0;
}

tho it gives ac for int chef[n+1],ass[n+1];

hello friends
my answer is for solve bug of other participants:

import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter;

public class CleaningUp { public static void main(String args[]) throws Exception{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter out=new PrintWriter(new BufferedOutputStream(System.out));
int n=Integer.parseInt(br.readLine());
for(int i=0;i<n;i++)
{

    String[] s=br.readLine().split(" ");
    int totalJobs=Integer.parseInt(s[0]);
    int JobsCompleted=Integer.parseInt(s[1]);

    String JobsCompletedList=br.readLine();
    String s1="";
    for(int j=1;j<=totalJobs;j++)
    {
        if(!(JobsCompletedList.contains(String.valueOf(j)))){
            s1+=j+" ";
        }
    }
    s1=s1.trim();
    s=s1.split(" ");
    String chefJobs="",assJobs="";
    for(int j=0;j<totalJobs-JobsCompleted;j++){
        if(j%2==0){
            chefJobs+=s[j]+" ";
        }
        else
            assJobs+=s[j]+" ";
    }

    out.println(chefJobs.trim());
    out.println(assJobs.trim());
}

out.close();

}
}
input:
1
13 1
12

your problem is that: when say 12 solved then 1 2 and 12 imagined solved and not run for this situation

t=int(raw_input())
def print_values(s):
if len(s)==0:
print " "
else:
for i in s:
print i,

for i in xrange(t):
n,m=map(int,(raw_input().split(’ ‘)))
finished=map(int,raw_input().strip().split(’ '))
unfinished=[i+1 for i in xrange(n) if (i+1) not in finished]
chef_job=[unfinished[i] for i in xrange(len(unfinished)) if i%2==0]
assis_job=[unfinished[i] for i in xrange(len(unfinished)) if i%2==1]
print_values(chef_job)
print “\n”
print_values(assis_job)

why this code has runtime error ?

Hi. Want to know where I went wrong with my code. It is giving wrong answer when submitted. Please help.
#include <stdio.h>

int main(void) {
int t, m, n, i, temp;
scanf("%d", &t);
while(t){
scanf("%d %d", &n, &m);
int jobs[n];
for(i=0;i<m;i++){
scanf("%d", &temp);
jobs[temp-1] = 1;
}
int assist[n/2 + 1];
int temp = 1, k=0;
for(i=0;i<n;i++){
if(jobs[i] != 1){
if(temp%2 != 0){
printf("%d “, i+1);
}
else{
assist[k] = i+1;
k++;
}
temp++;
}
}
printf(”\n");
if(k != 0){
for(i=0;i<(n/2)+1;i++){
if(assist[i] <= n && assist[i] > 0)
printf("%d ", assist[i]);
else
break;
}
}

    printf("\n");
    t--;
}
return 0;

}