Submission #429734

#TimeUsernameProblemLanguageResultExecution timeMemory
429734schseHandcrafted Gift (IOI20_gift)C++17
Compilation error
0 ms0 KiB
#include "gift.h"
#include <bits/stdc++.h>
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif

int construct(int n, int r, st#include "gift.h"
#include <bits/stdc++.h>
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif

int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x)
{

    int sb = 0;
    for (int i : x)
        sb |= i;
    if (sb == 1)
    {
        std::string s(n, 'R');
        craft(s);
        return 1;
    }
    else if (sb == 2)
    {
        for (int i = 0; i < a.size(); i++)
            if (a[i] == b[i])
                return 0;
        std::string s(n, 'R');
        for (int i = 0; i < n; i++)
            s[i] = i % 2 ? 'R' : 'B';
        craft(s);
        return 1;
    }
    else
    {
        vector<int> prefix(n);
        iota(prefix.begin(), prefix.end(), 0);
        for (int i = 0; i < a.size(); i++) //update single color
        {
            if (x[i] == 1)
            {
                for (int e = b[i] + 1; e < n; e++)
                    prefix[e] -= prefix[b[i]] - prefix[a[i]];
                for (int e = a[i] + 1; e < b[i] + 1; e++)
                    prefix[e] = prefix[a[i]];
            }
        }

        for (int i = 0; i < a.size(); i++) //check wetherpossible
        {
            if (x[i] == 2)
            {
                if (prefix[b[i]] - prefix[a[i]] < 1)
                    return 0;
            }
        }
        std::string s(n, 'R');
        for (int i = 0; i < n; i++)
            s[i] = prefix[i] % 2 ? 'R' : 'B';
        craft(s);
        return 1;
    }
}
d::vector<int> a, std::vector<int> b, std::vector<int> x)
{

    int sb = 0;
    for (int i : x)
        sb |= i;
    if (sb == 1)
    {
        std::string s(n, 'R');
        craft(s);
        return 1;
    }
    else if (sb == 2)
    {
        for (int i = 0; i < a.size(); i++)
            if (a[i] == b[i])
                return 0;
        std::string s(n, 'R');
        for (int i = 0; i < n; i++)
            s[i] = i % 2 ? 'R' : 'B';
        craft(s);
        return 1;
    }
    else
    {
        vector<int> prefix(n);
        iota(prefix.begin(), prefix.end(), 0);
        for (int i = 0; i < a.size(); i++) //update single color
        {
            if (x[i] == 1)
            {
                for (int e = a[i] + 1; e < b[i]; e++)
                    prefix[e] = prefix[a[i]];
                for (int e = b[i]; e < n; e++)
                    prefix[e] -= b[i] - a[i];
            }
        }

        for (int i = 0; i < a.size(); i++) //check wetherpossible
        {
            if (x[i] == 2)
            {
                if (prefix[b[i]] - prefix[a[i]] < 1)
                    return 0;
            }
        }
        std::string s(n, 'R');
        for (int i = 0; i < n; i++)
            s[i] = prefix[i] % 2 ? 'R' : 'B';
        craft(s);
        return 1;
    }
}

Compilation message (stderr)

gift.cpp:8:31: error: stray '#' in program
    8 | int construct(int n, int r, st#include "gift.h"
      |                               ^
gift.cpp:8:29: error: 'st' has not been declared
    8 | int construct(int n, int r, st#include "gift.h"
      |                             ^~
gift.cpp:8:40: error: expected ',' or '...' before string constant
    8 | int construct(int n, int r, st#include "gift.h"
      |                                        ^~~~~~~~
gift.cpp:10:20: error: expected ')' before ';' token
   10 | using namespace std;
      |                    ^
      |                    )
gift.cpp:8:14: note: to match this '('
    8 | int construct(int n, int r, st#include "gift.h"
      |              ^
gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int i = 0; i < a.size(); i++)
      |                         ~~^~~~~~~~~~
gift.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int i = 0; i < a.size(); i++) //update single color
      |                         ~~^~~~~~~~~~
gift.cpp:53:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for (int i = 0; i < a.size(); i++) //check wetherpossible
      |                         ~~^~~~~~~~~~
gift.cpp: At global scope:
gift.cpp:68:1: error: 'd' does not name a type
   68 | d::vector<int> a, std::vector<int> b, std::vector<int> x)
      | ^