답안 #26126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26126 2017-06-28T05:29:53 Z 조민규(#1100) Memory 2 (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;
                break;
            }
        }
        if(u)
        {
            x = i;
            for(k = 0; k<p; k++)
                 ans[mem[k][0]] = mem[k][1];
            break;
        }
    }

    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:73:26: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
             pos[i][1] = x;
                          ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1120 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 1120 KB Wrong Answer[3]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1120 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -