Submission #1103399

# Submission time Handle Problem Language Result Execution time Memory
1103399 2024-10-20T19:20:08 Z Tibi201 Mouse (info1cup19_mouse) C++14
Compilation error
0 ms 0 KB
#include <grader.h>
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <vector>
#include <time.h>
#define MAXN 256

int solved[MAXN];

std::set <int> cand[MAXN],used;
std::vector <int> q;
int left[MAXN];

void fill(int n){
    int i,j,n2;
    n2=n;
    for(i=0; i<n2; i++){
        left[i]=i+1;
    }
    for(auto x : used){
        left[x-1]=0;
    }
    for(i=0; i<n2; i++){
        if(left[i]==0){
            for(j=i+1; j<n2; j++){
                left[j-1]=left[j];
            }
            n2--;
        }
    }
    for(i=0; i<n; i++){
        if(solved[i]==0){
            j=rand()%n2;
            q[j]=left[j];
            for(j=j+1; j<n2; j++){
                left[j-1]=left[j];
            }
            n2--;
        }
    }
}

int solve(int n)
{
    srand(time(NULL));
    int i,j,x;
    auto y=used.begin();
    for(i=0; i<n; i++){
        for(j=1; j<=n; j++){
            cand[i].insert(j);
        }
    }
    for(i=0; i<n; i++){
        x=0;
        while(solved[x]==1)
            x++;
        for(j=x+1; j<n; j++){
            if((int)cand[j].size()<(int)cand[x].size())
                x=j;
        }
        y=cand[x].begin();
        y--;
        while((int)cand[i].size()>1){
            y++;
            if(y==cand[x].end())
                y=cand[x].begin();
            q[x+1]=*y;
            used.insert(*y);
            fill(n);
            if(query(q)==i){
                for(j=i; j<n; j++)
                    cand[j].erase(cand[j].find(q[j]));
            }
        }
    }
    return 0;
}

Compilation message

mouse.cpp: In function 'void fill(int)':
mouse.cpp:19:9: error: reference to 'left' is ambiguous
   19 |         left[i]=i+1;
      |         ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from grader.h:5,
                 from mouse.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mouse.cpp:13:5: note:                 'int left [256]'
   13 | int left[MAXN];
      |     ^~~~
mouse.cpp:22:9: error: reference to 'left' is ambiguous
   22 |         left[x-1]=0;
      |         ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from grader.h:5,
                 from mouse.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mouse.cpp:13:5: note:                 'int left [256]'
   13 | int left[MAXN];
      |     ^~~~
mouse.cpp:25:12: error: reference to 'left' is ambiguous
   25 |         if(left[i]==0){
      |            ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from grader.h:5,
                 from mouse.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mouse.cpp:13:5: note:                 'int left [256]'
   13 | int left[MAXN];
      |     ^~~~
mouse.cpp:27:17: error: reference to 'left' is ambiguous
   27 |                 left[j-1]=left[j];
      |                 ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from grader.h:5,
                 from mouse.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mouse.cpp:13:5: note:                 'int left [256]'
   13 | int left[MAXN];
      |     ^~~~
mouse.cpp:27:27: error: reference to 'left' is ambiguous
   27 |                 left[j-1]=left[j];
      |                           ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from grader.h:5,
                 from mouse.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mouse.cpp:13:5: note:                 'int left [256]'
   13 | int left[MAXN];
      |     ^~~~
mouse.cpp:35:18: error: reference to 'left' is ambiguous
   35 |             q[j]=left[j];
      |                  ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from grader.h:5,
                 from mouse.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mouse.cpp:13:5: note:                 'int left [256]'
   13 | int left[MAXN];
      |     ^~~~
mouse.cpp:37:17: error: reference to 'left' is ambiguous
   37 |                 left[j-1]=left[j];
      |                 ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from grader.h:5,
                 from mouse.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mouse.cpp:13:5: note:                 'int left [256]'
   13 | int left[MAXN];
      |     ^~~~
mouse.cpp:37:27: error: reference to 'left' is ambiguous
   37 |                 left[j-1]=left[j];
      |                           ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from grader.h:5,
                 from mouse.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
mouse.cpp:13:5: note:                 'int left [256]'
   13 | int left[MAXN];
      |     ^~~~
mouse.cpp: At global scope:
mouse.cpp:44:5: error: ambiguating new declaration of 'int solve(int)'
   44 | int solve(int n)
      |     ^~~~~
In file included from mouse.cpp:1:
grader.h:8:6: note: old declaration 'void solve(int)'
    8 | void solve(int N);
      |      ^~~~~