답안 #466364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
466364 2021-08-19T02:12:09 Z Namnamseo Memory 2 (JOI16_memory2) C++17
100 / 100
1 ms 332 KB
#include "Memory2_lib.h"
#include <vector>
#include <set>
#include <map>
using namespace std;

bool chk[100][100];
int  ret[100][100];

int flip(int a,int b){
    if(a>b) swap(a, b);
    int& ret=::ret[a][b];
    if(chk[a][b]) return ret;
    chk[a][b]=1;
    return ret = Flip(a, b);
}

void Solve(int T, int n){
    set<int> mxpt;
    mxpt.insert(0);
    mxpt.insert(1);

    vector<vector<int>> ans(n);

    for(int i=2; i<2*n; ++i){
        mxpt.insert(i);
        vector<int> pts(mxpt.begin(), mxpt.end());
        int k=pts.size();
        set<int> vars[k];
        set<int> szs;
        for(int a=0; a<k; ++a){
            for(int b=0; b<k; ++b) if(a!=b){
                vars[a].insert(flip(pts[a], pts[b]));
            }
            szs.insert(vars[a].size());
        }
        if(szs.size() == 1){
            continue;
        }
        mxpt.clear();
        for(int a=0; a<k; ++a){
            if(vars[a].size() != 1u) mxpt.insert(pts[a]);
            else ans[*vars[a].begin()].push_back(pts[a]);
        }
    }

    int a=*mxpt.begin(), b=*--mxpt.end();
    ans[flip(a,b)].push_back(a);
    ans[flip(a,b)].push_back(b);
    for(int i=0; i<n; ++i){
        Answer(ans[i][0], ans[i][1], i);
    }
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 288 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct