Блог пользователя islam-al-aarag

Автор islam-al-aarag, 10 лет назад, По-английски

I was coding problem 384D - Volcanoes after reading the editorial.
I keep getting wrong answer. I traced the code and tried all the small tests in the test cases but still can't find the bug.
The test case I fail in is large so I can't get a hold of it
Help is really appreciated. Here is my code:

[Edit]: I found the bug, thanks :)

Полный текст и комментарии »

  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится

Автор islam-al-aarag, 10 лет назад, По-английски

I've been debugging this for a while and I still can't tell why it exceeds the memory limit.
Can somebody help me?
Submission: 5723491

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор islam-al-aarag, 10 лет назад, По-английски

I was solving problem C from the last testing round 386C - Diverse Substrings
The idea I got was to handle substrings starting at different indices separately:
   1. You will do a precomputation next[i][26] telling you the next occurrence of each of the lower case letters from index i.
   2. You start at index i and each time you jump to the unseen character (using the precomputed array) with the least next occurrence    say k and all substrings starting at i and ending between the last jump and the current jump has diversity of the size of seen    characters so far.
The implementation was direct 5706503 and it was accepted.
I was playing around to optimize it when I thought I shouldn't loop on all characters and check what has been seen or not but instead maintain an actual set of the unseen characters so far and loop over them exclusively. The implementation was direct too 5706533.
To my surprise, this code timed out. I still can't explain why, it's supposed to be doing less loop iterations and hence less comparisons.
Any help would be appreciated.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -10
  • Проголосовать: не нравится

Автор islam-al-aarag, 11 лет назад, По-английски

I expected a new year's eve round :(

Полный текст и комментарии »

  • Проголосовать: нравится
  • +33
  • Проголосовать: не нравится

Автор islam-al-aarag, 11 лет назад, По-английски

Can someone tell me how this code exceeds 256MB? where n is at most 5k.

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.LinkedList;

public class G {
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(in.readLine());
        Point[] E = new Point[n];
        HashMap<String, Integer> H = new HashMap<String, Integer>();
        String[] N = new String[n * 2];
        int index = 0;
        for (int i = 0; i < n; i++) {
            String[] S = in.readLine().split(" ");
            if (!H.containsKey(S[0]))
                H.put(S[0], index++);
            if (!H.containsKey(S[1]))
                H.put(S[1], index++);
            int x = H.get(S[0]);
            N[x] = S[0];
            int y = H.get(S[1]);
            N[y] = S[1];
            E[i] = new Point(x, y);
        }
        boolean[][] F = new boolean[index][index];
        for (int i = 0; i < n; i++)
            F[E[i].x][E[i].y] = F[E[i].y][E[i].x] = true;
        short[][] C = new short[index][index];
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++) {
                int o1 = -1, o2 = -1;
                if (E[i].x == E[j].x) {
                    o1 = E[i].y;
                    o2 = E[j].y;
                } else if (E[i].x == E[j].y) {
                    o1 = E[i].y;
                    o2 = E[j].x;
                } else if (E[i].y == E[j].x) {
                    o1 = E[i].x;
                    o2 = E[j].y;
                } else if (E[i].y == E[j].y) {
                    o1 = E[i].x;
                    o2 = E[j].x;
                }
                if (o1 == -1)
                    continue;
                if (!F[o1][o2]) {
                    C[o1][o2]++;
                    C[o2][o1]++;
                }
            }
        out.println(index);
        for (int i = 0; i < index; i++) {
            int max = Integer.MIN_VALUE;
            for (int j = 0; j < index; j++)
                max = Math.max(max, C[i][j]);
            int cnt = 0;
            for (int j = 0; j < index; j++)
                if (C[i][j] == max && !F[i][j] && i != j)
                    cnt++;
            out.println(N[i] + " " + cnt);
        }
        out.flush();
        out.close();
    }
}

Полный текст и комментарии »

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится

Автор islam-al-aarag, 11 лет назад, По-английски

I can't register unofficially for the next Div2 round. Is it not possible anymore?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +18
  • Проголосовать: не нравится

Автор islam-al-aarag, 12 лет назад, По-английски

Is there a way to check all your old comments on posts?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор islam-al-aarag, 12 лет назад, По-английски
  • Проголосовать: нравится
  • -19
  • Проголосовать: не нравится

Автор islam-al-aarag, 12 лет назад, По-английски

I can not view any of the submitted codes of any contestant. Is the system in safe mode or is it just a bug??

Полный текст и комментарии »

Теги bug
  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится

Автор islam-al-aarag, 12 лет назад, По-английски

How can I join today's round virtually? to see where I would come if I joined.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится

Автор islam-al-aarag, 12 лет назад, По-английски

I found a bug concerning replying on comments. If you click reply more than once, you get more than one text area to write your comment. The more you click, the more areas you get.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

Автор islam-al-aarag, 12 лет назад, По-английски

Announcements were not working correctly today, I didn't know my solution was hacked because I got an announcement with the word (undefined) so I just ignored it. Same for the public announcement, I saw it when I was asking a question.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится

Автор islam-al-aarag, 12 лет назад, По-английски

What does Judgement Failed mean?

I got it 4 times in a row.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +9
  • Проголосовать: не нравится