« first day (299 days earlier)      last day (1115 days later) » 

5:29 AM
@JohnRennie hi sir
 
@satan29 hi :-)
 
sir have you worked with Pygames?
 
No, sorry :-(
 
ok, no problem
@JohnRennie @JohnRennie sir can you help me in downloading the module
 
pygames? Can't you just use pip ?
 
5:38 AM
it s sayinng pip is not recognizable...
i tried python -m pip install too
then it said python not found
 
Your path is wrong or python.exe isn't on the path.
 
how to check path? and change it?
 
Are you working ina command prompt?
 
yes'
 
I would close the current command prompt and open a new one. Then type python and press enter and see what happens.
If you get a command not recognised error then the problem is the path.
 
5:43 AM
i get a blank output
 
Can you remember where you installed Python? What directory?
@satan29 a blank output?
Ah, OK, yes Win10 does that.
It means the problem is the path. How do you normally run Python? From the Start menu? From a desktop icon?
 
desktop icon
should i check the location?
 
Yes, right click the icon and choose Properties and see what it is running.
 
"C:\Users\Shreshth Mehrotra\AppData\Local\Programs\Python\Python39\"
 
OK, in your command prompt type:
path="C:\Users\Shreshth Mehrotra\AppData\Local\Programs\Python\Python39\";%path%
 
5:48 AM
blank output
 
Now type python
 
it gave me some info about python
 
Ok, it's working.
type exit() to exit from Python.
python -m pip install should work now.
Shall I explain what the path command did?
 
sir before that
wait
 
Yes ... ?
 
5:53 AM
 
Isn't it just pygame not pygames
 
OOF yes
installed now
 
:-)
 
6:28 AM
@JohnRennie hi sir'
one problem
i have got the logic.
but theres one slight issue
t=int(input())
for i in range(0,t):
    n=int(input())
    i=[]
    d=[]
    for j in range(0,n):
        y=int(input())

        if(y in i):
            d.append(y)
        else:
            i.append(y)
    i.sort()
    d.sort()
    l=i+d
    for k in range(0,n):
        print(l[k],end=" ")
sir try this for one test case
t=1, n=7
but the input here
is like this
1
7
4
2
0
1
3
7
i want the input to be like this:
1
7
4 2 0 1 3 3 7
so i tried this code:
t=int(input())
for i in range(0,t):
    n=int(input())
    i=[]
    d=[]
    for j in range(0,n):
        a=input()
        m=a.split()
        for y in range(0,len(m)):
            print(m[y])
            if(m[y] in i):
                d.append(m[y])
            else:
                i.append(m[y])
    i.sort()
    d.sort()
    l=i+d
    for k in range(0,n):
        print(l[k],end=" ")
 
Your loops look odd ...
The outermost loop is range(0,t) to loop over all t tests - so far so good.
Then for each test you read the data using:
n = int(input)
alist = input()
a = split(a)
So now n is the number of integers in the list and a is the list.
 
a=split(a)?
    a=input()
    m=a.split()
sir my this part
is correct
 
Oops, a = split(alist)
 
i tied debugging
@JohnRennie rught
 
@satan29 yes, but you are doing that inside a loop:
for j in range(0,n):
 
6:37 AM
hmm
 
So you're calling split() n times in each test.
 
i gotcha
fixxed niw
@JohnRennie sir ill be back in a while
but pls meanwhile check my submission and have a look at the error message
 
I need to drop out to work for a bit ...
 
 
1 hour later…
8:04 AM
@JohnRennie hi
 
@satan29 hi :-)
 
sir can you look at the error now
 
yes sir...wth does that mean
 
I guess it means that although you did find a valid solution it wasn't the optimal solution. i.e. there are multiple possible solutions.
 
8:10 AM
oh
sir but my logic seems to be work...
otherwise it wouldve failed test case 2
@JohnRennie
 
Your logic certainly finds a solution otherwise it wouldn't pass tests 1 and 2. But does your logic find the best solution?
 
8:27 AM
what do you mean by "best"
 
The question says:
> For each test case print an array b1,b2,…,bn — the optimal reordering of a1,a2,…,an, so the sum of MEX on its prefixes is maximized.
But it doesn't define what it means by optimal ...
The error report says:
> wrong answer jury has better answer: jans = 4699, pans = 1753 (test case 24)
But it isn't clear what this means i.e. what are jans and pans ?
 
@JohnRennie sir basically the reordering such that the mex sum is max
sir the thing we need to maximize is the mex sum
 
I don't think I can comment further as it isn't clear what the error report means.
You can copy and paste the test data from the report so you can try it on your PC.
 
hmm
 
Am I missing something? Isn't it just a matter of sorting the array in ascending order?
 
8:41 AM
if the values are duplicated, then this wont work
consider the test example
the duplicated values should be in the end
this is essentially what i have done @JohnRennie
kept the duplicated values in the end
 
9:01 AM
Hmm, OK, so start with the unique values in ascending order. Then append any duplicates also in ascending order.
 
yes
actually, the ordering of the dupliates wont matter i guess
 
9:15 AM
This is my attempt. It's in the queue - the site seems slow today ...
num_tests = int(input())
for i in range(0,num_tests):
    n = int(input())
    in_list = list(map(int, input().split()))
    in_list.sort()

    # Copy the unique items into the output array, and copy any duplicates
    # into a separate array. We'll append the suplicates at the end.
    out_list = []
    dup_list = []
    last_num = -1
    for j in range(0,n):
        if in_list[j] != last_num:
            out_list.append(in_list[j])
            last_num = in_list[j]
        else:
            dup_list.append(in_list[j])
 
whats the logic?
 
It should be clear from the comments ...
 
oh oops
didnt see the comments
isnt that exactl what I have done?
 
I haven't looked at your code. I wanted to start with a clean slate.
If so my submission should fail with the same error you got.
 
fair
 
9:22 AM
What concerns me is if dup_list also contains duplicates. Do we need to apply the same logic to dup_list i.e. move any duplicates in dup_list to the end?
 
sir I dont suppose that will matter
 
The tests you're given contain no triplicated numbers so the issue didn't arise, but the test your code failed on does contain triplicates.
 
the MEX value will remain constant after the last distinct element
 
Hmm.
Remember what I said about programming being partly experimental?
 
XD yes
 
9:24 AM
If my submission fails with the same error as yours then I would try the experiment.
If it still fails all I've done is waste a bit of time.
 
for reference, heres my current code:
t=int(input())
for i in range(0,t):
    n=int(input())
    i=[]
    d=[]
    a=input()
    m=a.split()
    for y in range(0,len(m)):
        if(m[y] in i):
            d.append(m[y])
        else:
            i.append(m[y])
    i.sort()
    d.sort()
    l=i+d
    for k in range(0,n):
        print(l[k],end=" ")
 
It's still waiting in the queue. I wonder if the "hardware issues" the site warns about mean everything is running slowly.
 
yes I was about to say the same thing
 
OK, there's nothing we can do until the submissions run.
 
iytll be ok within 1.5 hrs i guess
ill solve a few chess puzzles in the meantime :-)
 
10:12 AM
@satan29 BOOM!
 
10:23 AM
sir, why did my code not work?
my output is damn weird for test case 3
what went wrong??
@JohnRennie
 
Let me have another look at your code ...
I note that you don't print a new line after each test output, though I guess that doesn't matter since it passed the first two trials.
Aha!
You are not converting the inputs to ints, so they are being sorted as strings not ints.
 
huh
OHHH
t=int(input())
for i in range(0,t):
    n=int(input())
    i=[]
    d=[]
    a=input()
    m=a.split()
    for y in range(0,len(m)):
        if(int(m[y]) in i):
            d.append(int(m[y]))
        else:
            i.append(int(m[y]))
    i.sort()
    l=i+d
    for k in range(0,n):
        print(l[k],end=" ")
 
The Pythony way to do this is using the map() function i.e. something like:
list(map(int, input().split()))
This inputs a string, splits it, applies the function int() to every element and converts the resulting integers as a list.
 
thats very useful, thanks
now it accepted my solution
 
:-)
 

« first day (299 days earlier)      last day (1115 days later) »