답안 #1027706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027706 2024-07-19T09:21:58 Z 김은성(#10950) Dungeon 2 (JOI16_dungeon2) C++14
0 / 100
1 ms 600 KB
#include "dungeon2.h"
#include <bits/stdc++.h>
using namespace std;
int ans[209];
vector<pair<int, int> > tree[209];
int root, dist, paridx[209], orgc[209];
int cnt = 1;
void extendtree(int v){
    int i;
    if(tree[v].empty()){
        for(i=1; i<=NumberOfRoads(); i++){
            Move(i, Color());
            //printf("cnt+1=%d Color=%d\n", cnt+1, Color());
            if(Color() == 3){
                Move(LastRoad(), Color());
                continue;
            }
            cnt++;
            orgc[cnt] = Color();
            //printf("orgc[%d]=%d\n", cnt, orgc[cnt]);
            paridx[cnt] = LastRoad();
           // printf("cnt=%d paridx=%d\n", cnt, paridx[cnt]);
            //printf("Line 23\n");
            Move(LastRoad(), 3);
            tree[v].push_back(make_pair(i, cnt));
            ans[dist]++;
            //printf("dist=%d\n", dist);
        }
    }
    else{
    for(i=0; i<tree[v].size(); i++){
            //printf("Line 32\n");
        Move(tree[v][i].first, 3);
        extendtree(tree[v][i].second);
    }
    }
    if(v==root)
        return;
    //printf("v=%d Line 38 paridx[v]=%d\n", v, paridx[v]);
    Move(paridx[v], Color());
}
void backcolor(int v){
    int i;
    //printf("v=%d\n", v);
    for(i=0; i<tree[v].size(); i++){
           // printf("Line 45 v=%d tree[v][i].second=%d\n", v, tree[v][i].second);
        Move(tree[v][i].first, orgc[v]);
       // printf("v=%d\n", v);
        //printf("v=%d tree[v][i].second=%d\n", v, tree[v][i].second);
        backcolor(tree[v][i].second);
    }
    if(v==root)
        return;
    //printf("v=%d\n", v);
            //printf("v=%d Line 54 paridx[v]=%d\n", v, paridx[v]);
    Move(paridx[v], orgc[v]);
}
void dfs(){
    root = 1;
    cnt = 1;
    int l = LastRoad();
    orgc[1] = Color();
    Move(1, 3);
    Move(LastRoad(), Color());
    for(int i=1; i<=208; i++)
        tree[i].clear();
    for(dist=1; dist<=3; dist++)
        extendtree(root);
    backcolor(root);
    for(int i=1; i<=NumberOfRoads(); i++){
       // printf("realmove\n");
        //printf("Line 73\n");
        Move(i, 2);
        if(Color() == 2){
           // printf("Line 74\n");
            Move(LastRoad(), 2);
            continue;
        }
        dfs();
    }
          //  printf("realmove\n");
    //printf("Line 83\n");
    if(l==-1)
        return;
    Move(l, 2);
}
void Inspect(int R)
{
    dfs();
    for(int i=1; i<=R; i++){
        Answer(i, ans[i]/2);
    }
}

Compilation message

dungeon2.cpp: In function 'void extendtree(int)':
dungeon2.cpp:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(i=0; i<tree[v].size(); i++){
      |              ~^~~~~~~~~~~~~~~
dungeon2.cpp: In function 'void backcolor(int)':
dungeon2.cpp:45:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(i=0; i<tree[v].size(); i++){
      |              ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -