Submission #55421

# Submission time Handle Problem Language Result Execution time Memory
55421 2018-07-07T09:08:52 Z SpaimaCarpatilor None (JOI16_memory2) C++17
0 / 100
3 ms 488 KB
#include "Memory2_lib.h"
#include<bits/stdc++.h>

using namespace std;

static int N, a[109], b[109], f[109], ap[109];
static map < pair < int, int >, int > mp;
static int q (int i, int j)
{
    i --, j --;
    if (i > j) swap (i, j);
    if (mp.count ({i, j})) ;
    else mp[{i, j}] = Flip (i, j);
    return mp[{i, j}] + 1;
}

static void giveAnswer ()
{
    for (int i=1; i<=N; i++)
    {
        int j1 = 0, j2 = 0;
        for (int j=1; j<=2 * N; j++)
            if (a[j] == i)
            {
                if (j1 == 0) j1 = j;
                else j2 = j;
            }
        Answer (j1 - 1, j2 - 1, i - 1);
    }
}

void Solve (int T, int nn)
{
    N = nn;
    for (int i=1; i<=2 * N; i++)
        if (ap[i] == 0)
        {
            memset (f, 0, sizeof (f));
            int lst = -1;
            for (int j=i + 1; j<=2 * N; j++)
                if (ap[j] == 0)
                {
                    b[j] = q (i, j);
                    if (++f[b[j]] == 3)
                    {
                        lst = j;
                        break;
                    }
                }
            if (lst == -1)
            {
                a[i] = N, ap[i] = 1;
                for (int j=i + 1; j<=2 * N; j++)
                    if (ap[j] == 0)
                        a[j] = b[j], ap[j] = 1;
                continue;
            }
            a[i] = b[lst], ap[i] = 1;
            for (int j=i + 1; j<lst; j++)
                if (ap[j] == 0 && b[j] != b[lst])
                    ap[j] = 1, a[j] = b[j];
        }
    giveAnswer ();
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 412 KB Output is correct
4 Correct 3 ms 412 KB Output is correct
5 Incorrect 3 ms 460 KB Wrong Answer[3]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 488 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -