Submission #26123

# Submission time Handle Problem Language Result Execution time Memory
26123 2017-06-28T05:25:33 Z 조민규(#1100) None (JOI16_memory2) C++14
0 / 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 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]++;
            mem[p][0] = j;
            mem[p++][1] = r;

            if(cnt[r] == 3)
            {
                for(k=0;k<p;k++)
                    if(mem[k][1] != r)
                        ans[mem[k][0]] = mem[k][1];
                ans[i] = r;
                u = 0;
                continue;
            }
        }
        if(u)
        {
            x = i;
            for(k = 0; k<p; k++)
                 ans[mem[k][0]] = mem[k][1];
        }
    }

    for(i = 0; i<2*N; i++)
    {
        //printf("ans %d = %d\n", i, ans[i]);
        if(pos[ans[i]][0] == -1)
            pos[ans[i]][0] = i;
        else
            pos[ans[i]][1] = i;
    }

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

    for(i = 0; i<N; i++)
        Answer(pos[i][0], pos[i][1], i);

	return;
}

Compilation message

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:72:26: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
             pos[i][1] = x;
                          ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1120 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1120 KB Output is correct
2 Incorrect 0 ms 1120 KB Wrong Answer[2]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1120 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -