Submission #26144

# Submission time Handle Problem Language Result Execution time Memory
26144 2017-06-28T06:05:03 Z 조민규(#1100) None (JOI16_memory2) C++14
100 / 100
0 ms 1120 KB
#include "Memory2_lib.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>

using namespace std;

int ans[100];
int cnt[100];
int mem[100][2];
int pos[50][2];

void put(int i, int v)
{
    ans[i] = v;
    if(pos[v][0] == -1)
        pos[v][0] = i;
    else
        pos[v][1] = i;
}

void Solve(int T, int N){

    memset(ans, -1, sizeof(ans));
    memset(pos, -1, sizeof(pos));

    bool u;
    int r, p, x, i, j, k;
    for(i = 0; i<2*N; i++)
    {
        if(ans[i] != -1)
            continue;

        u = 1;
        p = 0;
        memset(cnt, 0, sizeof(cnt));
        for(j = 0; j<2*N; j++)
        {
            if(ans[j] != -1 || i == j)
                continue;

            r = Flip(i, j);
            cnt[r]++;

            if(cnt[r] == 3)
            {
                u = 0;
                for(k = 0; k<p; k++)
                    if(mem[k][1] != r)
                        put(mem[k][0], mem[k][1]);
                break;
            }

            mem[p][0] = j;
            mem[p++][1] = r;
        }

        if(u)
        {
            x = i;
            for(k = 0; k<p; k++)
                put(mem[k][0], mem[k][1]);
            break;
        }
    }

    for(i = 0; i<N; i++)
    {
        if(pos[i][1] == -1)
            pos[i][1] = x;
        Answer(pos[i][0], pos[i][1], i);
    }

	return;
}

Compilation message

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:75:26: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
             pos[i][1] = x;
                          ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1120 KB Output is correct
2 Correct 0 ms 1120 KB Output is correct
3 Correct 0 ms 1120 KB Output is correct
4 Correct 0 ms 1120 KB Output is correct
5 Correct 0 ms 1120 KB Output is correct
6 Correct 0 ms 1120 KB Output is correct
7 Correct 0 ms 1120 KB Output is correct
8 Correct 0 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1120 KB Output is correct
2 Correct 0 ms 1120 KB Output is correct
3 Correct 0 ms 1120 KB Output is correct
4 Correct 0 ms 1120 KB Output is correct
5 Correct 0 ms 1120 KB Output is correct
6 Correct 0 ms 1120 KB Output is correct
7 Correct 0 ms 1120 KB Output is correct
8 Correct 0 ms 1120 KB Output is correct
9 Correct 0 ms 1120 KB Output is correct
10 Correct 0 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1120 KB Output is correct
2 Correct 0 ms 1120 KB Output is correct
3 Correct 0 ms 1120 KB Output is correct
4 Correct 0 ms 1120 KB Output is correct
5 Correct 0 ms 1120 KB Output is correct
6 Correct 0 ms 1120 KB Output is correct
7 Correct 0 ms 1120 KB Output is correct
8 Correct 0 ms 1120 KB Output is correct
9 Correct 0 ms 1120 KB Output is correct
10 Correct 0 ms 1120 KB Output is correct