GOLMINE - Editorial

I think that makes sense. Not sure.
Maybe we can add that one needs to mine at least 10^-18 amount of gold each time they want to switch? Or we can add that they won’t get anything if they take more than 10^18 time.

2 Likes

Second argument seems good .

2 Likes

Yes.
That’s what I was talking about. The problem need any one constraint to avoid the infinite time option.

Hey! It is a great problem, problem setter really got creative here. I couldn’t solve it but now I see the Lemma and it’s proof, I feel like stupid :roll_eyes:

By the way are there more such problems which I can practice? Or can anyone tell what is the “Type” of this problem so I can search and learn more about these kind of problems? It is called Game Theory?

The game ends in finite time. Even if you keep switching, the switches are instantaneous (given in the question) so time is always 0 in this case.

2 Likes

sorry , i think i should have written infinite moves. But now it becomes "The game ends in finite time but not in finite moves " .

Now here comes one more argument XD

1 Like

Used that also but it didn’t work.

One of the most controversial question it seems.

I faced the exact same issue. I overcomplicated it and discarded the idea of them working in the same mine at all times and ended up messing up the whole constest.

Why is this wrong ?

Here

1 Like

How could they possibly not get anything? Their moves are instantaneous. The sum of the total amount of gold that they get is always equal to the total amount of gold that was in the mines. They are always in a nonempty mine, so after any nonzero amount of time they must have mined some nonzero amount of gold. I made some other posts to discuss this here and here.

the lemma is correct but the proof is incorrect. let me try to give another proof.
in this explanation i am talking about total gold extracted in all n mines and not of a single mine.
their is one possible answer according to lemma say Chef and Chefu get x and y gold respectively. now let us assume one got another answer as x+a gold and y-a gold. now chefu got less gold than y so he will try to gain at least y gold by forcefully working in same mine where chef is. now the point is that for working together in mine it is sufficient that only one of them decide to work together then other have no option. if the other person tries to change mine, the first person can come to same mine instantaneously. also the idea that they will keep on changing mine indefinitely is rubbish as they can shift to all mines billions of times in 0 sec . so at last they have to work together if at least one of them want to work together.
so by this idea both chef and chefu can maintain at least x and y gold and since x+y is constant , therefore x and y is the only answer.

how (edit : i got it, thanks ) :rofl: :rofl: :rofl:. you’re genious.

1 Like

But if Chef has more than one choice of mine where he outperforms Chefu, he can immediately move to the one where Chefu isn’t.

How do you now decide whether they’re in the same mine or different mines, when each is switching mine infinitely many times per second?

This whole problem seems to have been a “trick question where you’ve got to approach it the same way as me or you get Wrong Answer”… even the test cases were bad, as they didn’t include ANY cases where Chef and Chefu had different mining rates… so we had to make our own test cases based on our own assumptions about what constitutes “optimal”, which it seems many interpreted as “optimise your own mining speed, keeping an eye out for where your competitor will be if there’s a choice”. We were given zero opportunity to discover we’d made different assumptions to the problem setter before submitting and getting a “wrong answer”, and zero opportunity to discover what the correct assumptions were based on a known test case.

take this input :-

3
10 1 4
10 2 3
10 3 1

if they work in the mines where they extract max gold/day rate first then procedure will go like
rates would be like

player 1          player 2
    10              2.5
    5               3.33
    3.33            10

player 2 will go to 3rd mine first then 2nd and then 1st
player 1 will go to 1st mine first then 2nd and then 3rd

after day one both will have 10 gold each and only 2nd mine is remaining to mine (as both have gathered 10 from 1st and 3rd)
and on second they both wont be able to gather same on that day as now their rates are different
final score would be player 1 : with 16 and player 2 with 14.

but what if you go with working in same mines at time :

        p1    p2
mine1    8     2
mine2    14    6
mine3    16.5  13.5

test cases were wrong indeed so…

I don’t see anything wrong with the problem statement. It might be lack of understanding from your side. Don’t blame the setters for your mistake or leave this platform if you find problem statements here “poorly constructed”.

Okay I see one reply from kingofnumber. Do you agree with him ?

I have written the code in 2 languges, the logic being same, one in C++ and another in JAVA. Can please comeone tell my why the C++ code is giving WA while the JAVA code is correct? Thank you in advance. Below are the two code

/JAVA/
Link: CodeChef: Practical coding for everyone

import java.util.;
import java.io.
;
class GOLMINE{
static class FastScanner {
BufferedReader br;
StringTokenizer st;
FastScanner(InputStream stream) {
try {
br = new BufferedReader(new
InputStreamReader(stream));
} catch (Exception e) {
e.printStackTrace();
}
}

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    String nextLine() {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
 }
 public static void main(String args[]){
      try{
           FastScanner sc=new FastScanner(System.in);
           int t=sc.nextInt();
           while(t-->0){
                int n=sc.nextInt();
                double g,a,b;
                double ga=0.0,gb=0.0;
                for(int i=0; i<n; i++){
                    g=sc.nextDouble();
                    a=sc.nextDouble();
                    b=sc.nextDouble();
                    ga += (b*g) / (a+b);
                    gb += (a*g) / (a+b);
                }
                System.out.println(ga+" "+gb);
           }
      }catch(Exception e){}
 }

}

/********************** C++ **********************/
Link: CodeChef: Practical coding for everyone

#include
#include
#include
#include <bits/stdc++.h>
#include <stdbool.h>
#include <math.h>
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define show(x) cout << (#x) << " : " << x << endl;
#define forn(i,a,b) for(int (i)=(a);(i) < (b); (i)++)
using namespace std;

void solve(){
int n;
cin >> n;
double ga=0.0,gb=0.0;
double g[n],a[n],b[n];
forn(i,0,n){
cin >> g[i] >> a[i] >> b[i];
}
forn(i,0,n){
ga+= (b[i]/(b[i]+a[i])) * g[i];
gb+= (a[i]/(b[i]+a[i]) )* g[i];
}
cout << ga << " " << gb << endl;
}

int main() {
fastio();
int nooftestcases;
cin >> nooftestcases;
forn(i,0,nooftestcases){
solve();
}
return 0;
}

Although when I am adding setprecision(6) its working,
WORKING C++ CODE

/********************** C++ **********************/
Link: CodeChef: Practical coding for everyone

#include
#include
#include
#include <bits/stdc++.h>
#include <stdbool.h>
#include <math.h>
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define show(x) cout << (#x) << " : " << x << endl;
#define forn(i,a,b) for(int (i)=(a);(i) < (b); (i)++)
using namespace std;

void solve(){
int n;
cin >> n;
double ga=0.0,gb=0.0;
double g[n],a[n],b[n];
forn(i,0,n){
cin >> g[i] >> a[i] >> b[i];
}
forn(i,0,n){
ga+= (b[i]/(b[i]+a[i])) * g[i];
gb+= (a[i]/(b[i]+a[i]) )* g[i];
}
cout << fixed << setprecision(6)<< ga << " " << gb << endl;
}

int main() {
fastio();
int nooftestcases;
cin >> nooftestcases;
forn(i,0,nooftestcases){
solve();
}
return 0;
}