Submission #48146

# Submission time Handle Problem Language Result Execution time Memory
48146 2018-05-10T10:33:56 Z antimirage Library (JOI18_library) C++14
Compilation error
0 ms 0 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;


const int N = 1005;

pair <int, int> ar[N];

bool used[N];

void Solve(int N)
{
    int n = N;
    vector <int> vec(n, 0), ans(n, 0);

    for (int i = 0; i < n; i++)
    {
        vec[i] = 1;
        for (int j = i + 1; j < n; j++)
        {
            vec[j] = 1;
            int res = Query(vec);

            if (res == 1)
            {
                if (ar[i].fr == 0)
                    ar[i].fr = j;
                else
                    ar[i].sc = j;

                if (ar[j].fr == 0)
                    ar[j].fr = i;
                else
                    ar[j].sc = i;
            }
            vec[j] = 0;
        }
        vec[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        if (ar[i].sc == 0)
        {
            ans[0] = i;
            break;
        }
    }
    used[ ans[0] ] = 1;

    for (int i = 1; i < n; i++)
    {
        if (!used[ ar[ ans[i - 1] ].fr ])
        {
            ans[i] = ar[ ans[i - 1] ].fr;
            used[ ans[i] ] = 1;
        }
        else if (!used[ ar[ ans[i - 1] ].sc ])
        {
            ans[i] = ar[ ans[i - 1] ].sc;
            used[ ans[i] ] = 1;
        }
    }
    for (int i = 0; i < n; i++)
        ans[i]++;

	Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:28:27: error: 'struct std::pair<int, int>' has no member named 'fr'
                 if (ar[i].fr == 0)
                           ^~
library.cpp:29:27: error: 'struct std::pair<int, int>' has no member named 'fr'
                     ar[i].fr = j;
                           ^~
library.cpp:31:27: error: 'struct std::pair<int, int>' has no member named 'sc'
                     ar[i].sc = j;
                           ^~
library.cpp:33:27: error: 'struct std::pair<int, int>' has no member named 'fr'
                 if (ar[j].fr == 0)
                           ^~
library.cpp:34:27: error: 'struct std::pair<int, int>' has no member named 'fr'
                     ar[j].fr = i;
                           ^~
library.cpp:36:27: error: 'struct std::pair<int, int>' has no member named 'sc'
                     ar[j].sc = i;
                           ^~
library.cpp:44:19: error: 'struct std::pair<int, int>' has no member named 'sc'
         if (ar[i].sc == 0)
                   ^~
library.cpp:54:37: error: 'struct std::pair<int, int>' has no member named 'fr'
         if (!used[ ar[ ans[i - 1] ].fr ])
                                     ^~
library.cpp:56:39: error: 'struct std::pair<int, int>' has no member named 'fr'
             ans[i] = ar[ ans[i - 1] ].fr;
                                       ^~
library.cpp:59:42: error: 'struct std::pair<int, int>' has no member named 'sc'
         else if (!used[ ar[ ans[i - 1] ].sc ])
                                          ^~
library.cpp:61:39: error: 'struct std::pair<int, int>' has no member named 'sc'
             ans[i] = ar[ ans[i - 1] ].sc;
                                       ^~
library.cpp:65:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = 0; i < n; i++)
     ^~~
library.cpp:68:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  Answer(ans);
  ^~~~~~