justHusam's blog

By justHusam, 3 months ago, In English,

Hello Codeforces,

I would like to invite you all to participate in the 2017 JUST Programming Contest 3.0 of Jordan University of Science and Technology. The contest was originally held on 26th of August , and it will launch in Codeforces Gym on Wednesday 30 August 2017 15:00 UTC.

The problems were prepared by Vendetta. (Ibraheem Tuffaha), justHusam (Husam Musleh), Alaa_AbuHantash (Αlαα Abu Hantash), and 0xAC (Mohammad Al-Tahhan).

The duration of the contest is 4.5 hours, and the registration will be open 6 hours before the start of the contest.

Good luck for everyone, and I wish you all Accepted solutions.

UPD: Registration is currently open.

UPD: The contest will start in 30 minutes.

 
 
 
 
  • Vote: I like it  
  • +61
  • Vote: I do not like it  

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

For problem B can anybody explain why this approach gives WA: count the number of each a[i], and each b[i] inside a map countA and countB, then iterate one of the array and add the max of each element that it's count is > 0 in both maps (countA and countB) to the answer.

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve problem J ?

  • »
    »
    3 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    let's suppose your lines of boxes starts with box with index a and finishes with box with index b, if you play first you can pick either box a or b, leaving the other player with boxes (a+1..b) or (a..b-1) and we know he will do the optimal move and leave us with either (a+2..b) or (a+1..b-1) (if we picked box "a" in the previous turn) and (a+1..b-1) or (a..b-2) (if we picked "b" in the previous turn). since this is a zero-sum game, we can think of his move as he's trying to minimize our score. so our next move will be in the position that gives us the minimum score. now let's go back to the beginning of the game before picking either a or b, we pick the box that gives us a maximum minimum in our next possible moves, and we do it recursively for all positions of boxes we can achieve. more formally,

    Spoiler

    my solution

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

For problem A can anybody give a HINT and thanks in advance ^^

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    If the amount of money you have is TotalMoney, and the price per orange is OrangePrice then the number of oranges you can buy is (assuming that TotalMoney is divisible by OrangePrice):

    We can use this equation to find TotalMoney, which is equal to:

    TotalMoney = Oranges × OrangePrice

    Let's take the first test case as an example to explain the solution. If the price of the orange was increased by 25%, then the new price is equal to:

    NewOrangePrice = OrangePrice × 1.25

    The number of oranges that can be bought after the price increase is equal to:

    From the problem statement, we know that the amount of money didn't change, which mean:

    NewTotalMoney ≡ TotalMoney

    So, we can write the equation as follows:

    Also, we know the following from the explanation above:

    TotalMoney ≡ Oranges × OrangePrice

    NewOrangePrice ≡ OrangePrice × 1.25

    So, we can write the equation as follows:

    Which can be written as follows:

    In general, to calculate the answer you can use the following equation:

    .

    To avoid floating-point issues with compilers, you can multiply the equation by 100 to get the following equation:

    .

»
3 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

IS here anyone can put the solutions of the 12 pbs here please ?

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone share how to solve problem I. Was it a simple BFS but it was giving Wrong Answer on my submission.

  • »
    »
    2 months ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    We can find the current number of other figures can be reached, the establishment of a map, the shortest road

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone give me hint with problem D ?

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    BFS

    and Remember that you can't do the following transitions:

    1 <-> 6 (ie: if top is 1, you can go to 3,4,5,2 but not 6, same for 6 can go the same set but not 1)

    3 <-> 4

    5 <-> 2

    • »
      »
      »
      5 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Oh, I solved it , but very thanks you , btw, I am stuck at problem G, my idea is count hash code of all strings's suffix, but I don't know how to map value ?

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Hmmm, you approach seems like it'll get a TLE for me.

        Anyway, the problem is solvable by inserting the reverse of each string in a Tries. Think about it.

»
4 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

problem B ~~~~~ public static void main(String[] args) { MyScanner scanner=new MyScanner();

int test=scanner.nextInt();
while(test-->0){
    int length=scanner.nextInt();
    int[] rowArray=new int[length];
    int[] colArray=new int[length];
    HashMap<Integer, Integer> colCount=new HashMap<>();
    for(int i=0;i<length;i++){

       int row=scanner.nextInt();
       int col=scanner.nextInt();
       rowArray[i]=row;
       colArray[i]=col;

       if(colCount.get(col)==null){
         colCount.put(col, 0);
       }
       colCount.put(col, colCount.get(col)+1);
    }

    int count=0;
    for(int i=0;i<length;i++){
       if(colCount.get(rowArray[i])!=null){
         if(rowArray[i]==colArray[i]){

          count=count+colCount.get(rowArray[i])-1;
         }
         else{
          count=count+colCount.get(rowArray[i]);
         }
       }

    /* if(colToRow.get(rowArray[i])!=null){
         for(int row:colToRow.get(rowArray[i]).keySet()){
          if(row!=colArray[i]){
              count=count+colToRow.get(rowArray[i]).get(row);
          }
          else{
              count=count+colToRow.get(rowArray[i]).get(row)-1;
          }
         }    
       }*/

    }

    System.out.println(count);
}


}

~~~~~

can some one tell me whats going wrong here

i am collecting frequency of columns in a map and iterating through the array if any row is present in the map and is row != column : then count=count+cols[current_row] else if current_row==current_col: then count=count+cols[current_row]-1