답안 #315113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315113 2020-10-22T02:40:19 Z daniel920712 Mouse (info1cup19_mouse) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include "grader.h"

using namespace std;
vector < vector < int > > all;
vector < int > con;
vector < int > how;
int cmp(vector < int > a, vector < int > b)
{
    int N=a.size(),con=0;
    for(i=0;i<N;i++) if(a[i]==b[i]) con++;
    return con;
}
void solve(int N)
{
    how.clear();
    int i,now=0,x,ok=1,t=0;
    for(i=0;i<N;i++) how.push_back(i+1);
    while(t!=N)
    {
        for(i=0;i<N;i++) how[i]=i+1;
        do
        {
            ok=1;
            x=0;
            for(auto i:all) 
            {
                if(cmp(i,how)!=con[x]) ok=0;
                x++;
            }
            if(ok)
            {
                t=query(how);
                con.push_back(t);
                all.push_back(how);
                break;
                
            }
        }while(next_permutation(how.begin(),how.end())!=0);
    }
    

}


Compilation message

mouse.cpp: In function 'int cmp(std::vector<int>, std::vector<int>)':
mouse.cpp:14:9: error: 'i' was not declared in this scope
   14 |     for(i=0;i<N;i++) if(a[i]==b[i]) con++;
      |         ^
mouse.cpp: In function 'void solve(int)':
mouse.cpp:20:11: warning: unused variable 'now' [-Wunused-variable]
   20 |     int i,now=0,x,ok=1,t=0;
      |           ^~~