답안 #1004084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004084 2024-06-21T04:52:12 Z De3b0o Flights (JOI22_flights) C++17
0 / 100
300 ms 540672 KB
#include "Ali.h"
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)

using namespace std;

vector<ll> adj[10009];
ll n;
ll ds[10009][10009];

void dfs(ll x , ll p , ll d , ll o)
{
    ds[o][x]=d;
    for(auto it : adj[x])
    {
        if(it==p)
            continue;
        dfs(it,x,d+1,o);
    }
}

void Init(int N, std::vector<int> U, std::vector<int> V)
{
    n=N;
    vector<ll> v;
    for(int i = 0 ; n>i ; i++)
        v.pb(i);
    random_shuffle(v.begin(),v.end());
    for(int i = 0 ; n>i ; i++)
        SetID(i,v[i]);
    for(int i = 0 ; N-1>i ; i++)
    {
        adj[v[U[i]]].pb(v[V[i]]);
        adj[v[V[i]]].pb(v[U[i]]);
    }
}

std::string SendA(std::string S)
{
    ll a3 = 0;
    ll b = 1;
    for(int i = 0 ; 4>i ; i++)
    {
        if(S[i]=='1')
            a3+=b;
        b*=2;
    }
    ll a1 = 0 , a2 = 0;
    b=1;
    for(int i = 4 ; 4+a3>i ; i++)
    {
        if(S[i]=='1')
            a1+=b;
        b*=2;
    }
    b=1;
    for(int i = 4+a3 ; 20>i ; i++)
    {
        if(S[i]=='1')
            a2+=b;
        b*=2;
    }
    ll w = (1<<13);
    set<ll> sum;
    ll po = 20-a3-4;
    for(ll i = 0 ; w>i ; i++)
    {
        ll su = a2+(i<<(po));
        if(2*n-3>=su)
            sum.in(su);
    }
    string s = "";
    for(ll i = 0 ; n>i ; i++)
    {
        ll x = i , y = i+a1;
        if(y>=n)
            break;
        ll su = x+y;
        if(sum.find(su)==sum.end())
            continue;
        dfs(x,-1,0,x);
        b = 1;
        for(int i = 0 ; 15>i ; i++)
        {
            if((x+y)&b)
                s+='1';
            else
                s+='0';
            b*=2;
        }
        b=1;
        for(int i = 0 ; 14>i ; i++)
        {
            if(ds[x][y]&b)
                s+='1';
            else
                s+='0';
            b*=2;
        }
    }
    return s;
}
#include "Benjamin.h"
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)

using namespace std;

ll y , x;

std::string SendB(int N, int X, int Y)
{
    x=X;
    y=Y;
    ll a1 = abs(X-Y);
    ll a2 = X+Y;
    ll a3 = 0;
    ll b = a1;
    while(b)
    {
        a3++;
        b/=2;
    }
    //cout << a1 << " " << a2 << " " << a3 << "\n";
    string s = "";
    b=1;
    for(int i = 0 ; 4>i ; i++)
    {
        if(b&a3)
            s+='1';
        else
            s+='0';
        b*=2;
    }
    b=1;
    for(int i = 0 ; a3>i ; i++)
    {
        if(b&a1)
            s+='1';
        else
            s+='0';
        b*=2;
    }
    b=1;
    for(int i = a3+4 ; 20>i ; i++)
    {
        if(b&a2)
            s+='1';
        else
            s+='0';
        b*=2;
    }
    //cout << s << "\n";
    return s;
}

int Answer(std::string T)
{
    ll ans;
    for(int i = 0 ; T.size()>i ; i+=29)
    {
        ll b = 1;
        ll sum = 0;
        for(int j = i ; i+15>j ; j++)
        {
            if(T[j]=='1')
                sum+=b;
            b*=2;
        }
        ll ans1 = 0;
        b=1;
        for(int j = i+15 ; i+29>j ; j++)
        {
            if(T[j]=='1')
                ans1+=b;
            b*=2;
        }
        if(x+y==sum)
            ans=ans1;
    }
    return ans;
}

Compilation message

grader_ali.cpp:10:8: warning: '{anonymous}::_randmem' defined but not used [-Wunused-variable]
   10 |   char _randmem[12379];
      |        ^~~~~~~~

Benjamin.cpp: In function 'int Answer(std::string)':
Benjamin.cpp:74:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   74 |     for(int i = 0 ; T.size()>i ; i+=29)
      |                     ~~~~~~~~^~
Benjamin.cpp:95:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   95 |     return ans;
      |            ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 920 KB Output is correct
2 Correct 0 ms 920 KB Output is correct
3 Correct 0 ms 920 KB Output is correct
4 Correct 0 ms 920 KB Output is correct
5 Correct 0 ms 920 KB Output is correct
6 Correct 105 ms 46540 KB Output is correct
7 Correct 114 ms 101704 KB Output is correct
8 Correct 122 ms 102976 KB Output is correct
9 Correct 116 ms 102128 KB Output is correct
10 Correct 22 ms 62056 KB Output is correct
11 Correct 54 ms 86336 KB Output is correct
12 Correct 44 ms 83596 KB Output is correct
13 Failed 121 ms 127152 KB Unexpected end of file - int32 expected (Bruno)
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 300 ms 540672 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -