제출 #1182079

#제출 시각아이디문제언어결과실행 시간메모리
1182079tgirolami09사육제 (CEOI14_carnival)C++20
20 / 100
25 ms408 KiB
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int nbPeople;
    scanf("%d",&nbPeople);
    vector<int> answer(nbPeople,-1);
    printf("%d ",nbPeople);
    for (int i = 0;i<nbPeople;++i){
        printf("%d ",i+1);
    }
    printf("\n");
    fflush(stdout);
    int nbTotalCostumes;
    scanf("%d",&nbTotalCostumes);
    //Ceux qui reste sont de la derniere couleur
    for (int currentCostume = 1;currentCostume<nbTotalCostumes;++currentCostume){
        int firstOfCostume;
        for (int idx = 0;idx<nbPeople;++idx){
            if (answer[idx]==-1){
                answer[idx] = currentCostume;
                firstOfCostume = idx;
                break;
            }
        }
        for (int other = firstOfCostume+1;other<nbPeople;++other){
            if (answer[other]==-1){
                printf("2 %d %d\n",firstOfCostume+1,other+1);
                fflush(stdout);
                int nbCostumes;
                scanf("%d",&nbCostumes);
                if (nbCostumes==1){
                    answer[other] = answer[firstOfCostume];
                }
            }
        }
    }
    printf("0 ");
    for (int i : answer){
        int toPrint = i;
        if (toPrint==-1){
            toPrint = nbTotalCostumes;
        }
        printf("%d ",toPrint);
    }
}

컴파일 시 표준 에러 (stderr) 메시지

carnival.cpp: In function 'int main()':
carnival.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d",&nbPeople);
      |     ~~~~~^~~~~~~~~~~~~~~~
carnival.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d",&nbTotalCostumes);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:33:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |                 scanf("%d",&nbCostumes);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...