Submission #506159

# Submission time Handle Problem Language Result Execution time Memory
506159 2022-01-11T18:24:05 Z jerzyk Saveit (IOI10_saveit) C++17
Compilation error
0 ms 0 KB
#include "grader.h"
#include "encoder.h"
#include<bits/stdc++.h>

typedef long long ll;
using namespace std;
const int N = 1000 + 7;
vector<int>ed[N];
int tab[38][1000 + 7], wsk[N];

ll Return3(int v, int h)
{
    ll w, m;
    for(int i = 1; i <= h; ++i)
    {
        if(tab[i][v] == tab[i][wsk[i]])
            m = 1;
        if(tab[i][v] > tab[i][wsk[i]])
            m = 2;
        w += m * pow(3LL, (ll)i - 1);
    }
    return w;
}

void PrintBits(ll x, int l)
{
    for(int i = 1; i <= l; ++i)
    {
        encode_bit(x % 2);
        x /= 2;
    }
}

void DFS(int v)
{
    for(int i = 0; i < (int)ed[v].size(); ++i)
    {
        if(wsk[ed[v][i]] == 0)
        {
            wsk[ed[v][i]] = v;
            DFS(ed[v][i]);
        }
    }
}

void BFS(int n, int s)
{
    int v;
    queue<int> q;
    for(int i = 1; i <= n; ++i)
        tab[s][i] = N * 2;
    tab[s][s] = 0;
    q.push(s);
    while(q.size() > 0)
    {
        v = q.front();
        q.pop();
        for(int i = 0; i < (int)ed[v].size(); ++i)
        {
            if(tab[s][ed[v][i]] > tab[s][v] + 1)
            {
                tab[s][ed[v][i]] = tab[s][v] + 1;
                q.push(ed[v][i]);
            }
        }
    }
}

void encode(int n, int h, int m, int* a, int* b)
{
    for(int i = 0; i < m; ++i)
    {
        ed[a[i] + 1].push_back(b[i] + 1);
        ed[a[i] + 1].push_back(b[i] + 1);
    }
    for(int i = 1; i <= h; ++i)
        BFS(n, i);
    wsk[1] = 1;
    DFS(1);
    for(int i = 2; i <= h; ++i)
        PrintBits(tab[i][1], 10);
    for(int i = 2; i <= n; ++i)
    {
        PrintBits(wsk[i], 10);       
        PrintBits(Return3(i, h), 58);
    }
}
#include "grader.h"
#include "encoder.h"
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N = 10000 + 7;
int odl[37][N], dod[37][N], ws[N];
vector<int>ed[N];

void DFS(int v, int h)
{
    for(int i = 1; i <= h; ++i)
        odl[i][v] = dod[i][v] + odl[i][ws[v]];
    for(int i = 0; i < (int)ed[v].size(); ++i)
        DFS(ed[v][i]);
}

void Dod(ll l, int v, int h)
{
    for(int i = 1; i <= h; ++i)
    {
        if(l % 3LL == 0)
            dod[i][v] = -1;
        if(l % 3LL == 2)
            dod[i][v] = 1;
    }
}

ll ReadBits(int n)
{
    int b;
    ll w = 0LL;
    for(int i = 0; i < n; ++i)
    {
        b = decode_bit();
        w += pow(2LL, j) * b;
    }
    return w;
}

void decode(int n, int h)
{
    for(int i = 2; i <= h; ++i)
        odl[i][1] = ReadBits(10);
    for(int i = 2; i <= n; ++i)
    {
        ws[i] = ReadBits(10);
        ed[ws[i]].push_back(i);
        Dod(ReadBits(58), i, h);
    }
    DFS(1);
    for(int i = 1; i <= h; ++i)
        for(int j = 1; j <= n; ++j)
            hops(i - 1, j - 1, odl[i][j]);
}

Compilation message

encoder.cpp: In function 'll Return3(int, int)':
encoder.cpp:22:12: warning: 'w' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |     return w;
      |            ^
encoder.cpp:20:16: warning: 'm' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |         w += m * pow(3LL, (ll)i - 1);
      |              ~~^~~~~~~~~~~~~~~~~~~~~

decoder.cpp: In function 'void DFS(int, int)':
decoder.cpp:14:40: error: reference to 'ws' is ambiguous
   14 |         odl[i][v] = dod[i][v] + odl[i][ws[v]];
      |                                        ^~
In file included from /usr/include/c++/10/istream:991,
                 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 decoder.cpp:3:
/usr/include/c++/10/bits/istream.tcc:1024:5: note: candidates are: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::ws(std::basic_istream<_CharT, _Traits>&)'
 1024 |     ws(basic_istream<_CharT, _Traits>& __in)
      |     ^~
decoder.cpp:8:29: note:                 'int ws [10007]'
    8 | int odl[37][N], dod[37][N], ws[N];
      |                             ^~
decoder.cpp:16:21: error: too few arguments to function 'void DFS(int, int)'
   16 |         DFS(ed[v][i]);
      |                     ^
decoder.cpp:11:6: note: declared here
   11 | void DFS(int v, int h)
      |      ^~~
decoder.cpp: In function 'll ReadBits(int)':
decoder.cpp:37:23: error: 'j' was not declared in this scope
   37 |         w += pow(2LL, j) * b;
      |                       ^
decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:48:9: error: reference to 'ws' is ambiguous
   48 |         ws[i] = ReadBits(10);
      |         ^~
In file included from /usr/include/c++/10/istream:991,
                 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 decoder.cpp:3:
/usr/include/c++/10/bits/istream.tcc:1024:5: note: candidates are: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::ws(std::basic_istream<_CharT, _Traits>&)'
 1024 |     ws(basic_istream<_CharT, _Traits>& __in)
      |     ^~
decoder.cpp:8:29: note:                 'int ws [10007]'
    8 | int odl[37][N], dod[37][N], ws[N];
      |                             ^~
decoder.cpp:49:12: error: reference to 'ws' is ambiguous
   49 |         ed[ws[i]].push_back(i);
      |            ^~
In file included from /usr/include/c++/10/istream:991,
                 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 decoder.cpp:3:
/usr/include/c++/10/bits/istream.tcc:1024:5: note: candidates are: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::ws(std::basic_istream<_CharT, _Traits>&)'
 1024 |     ws(basic_istream<_CharT, _Traits>& __in)
      |     ^~
decoder.cpp:8:29: note:                 'int ws [10007]'
    8 | int odl[37][N], dod[37][N], ws[N];
      |                             ^~
decoder.cpp:52:10: error: too few arguments to function 'void DFS(int, int)'
   52 |     DFS(1);
      |          ^
decoder.cpp:11:6: note: declared here
   11 | void DFS(int v, int h)
      |      ^~~