Submission #707605

# Submission time Handle Problem Language Result Execution time Memory
707605 2023-03-09T13:36:53 Z bin9638 Two Transportations (JOI19_transportations) C++17
8 / 100
415 ms 27532 KB
#include<bits/stdc++.h>

#ifndef SKY
#include "Azer.h"
#endif // SKY

using namespace std;
#define N 2010
#define ll long long
#define ii pair<int,int>
#define fs first
#define sc second
#define pb push_back

int id=2,m,n,dem=0,edge[N][5],dp[N],ktr[N];
vector<ii>g[N];

#ifdef SKY
void SendA(bool y)
{
    cout<<y<<endl;
}
#endif // SKY

void InitA(int cc, int A, vector<int> U, vector<int> V,  vector<int> C)
{
    n=cc;
    for(int i=0;i<A;i++)
    {
        int u=U[i],v=V[i],L=C[i];
        g[u].pb({L,v});
        g[v].pb({L,u});
        //cout<<u<<" "<<v<<" "<<L<<endl;
    }
}

void ReceiveA(bool x)
{
    if(dem<11)
    {
        if(x==1)
            m+=(1<<(dem));
    }else
    {
        if(dem%11==0)
            id=(id+1)%3;
        if(x==1)
            edge[(dem-11)/33][id]+=(1<<(dem%11));
    }
    dem++;
}

vector<int> Answer()
{
    for(int i=0;i<m;i++)
    {
        int u=edge[i][0],v=edge[i][1],L=edge[i][2];
        g[u].pb({L,v});
        g[v].pb({L,u});
    }
    priority_queue<ii>s;
    memset(dp,0x3f3f,sizeof(dp));
    dp[0]=0;
    s.push({0,0});
    while(!s.empty())
    {
        ii cc=s.top();
        s.pop();
        int u=cc.sc,L=-cc.fs;
        if(ktr[u]==1)
            continue;
        ktr[u]=0;
        for(auto v:g[u])
            if(dp[v.sc]>L+v.fs)
            {
                dp[v.sc]=L+v.fs;
                s.push({-dp[v.sc],v.sc});
            }
    }
  vector<int> ans(n);
  for(int i=0;i<n;i++)
    ans[i]=dp[i];
    return ans;
}

#ifdef SKY
int main()
{
    freopen("Azer.inp","r",stdin);
    freopen("Azer.out","w",stdout);
    int n,A;
    vector<int>U,V,C;
    cin>>n>>A;
    for(int i=0;i<A;i++)
    {
        int u,v,c;
        cin>>u>>v>>c;
        U.pb(u);
        V.pb(v);
        C.pb(c);
    }
    InitA(n,A,U,V,C);
    for(int i=0;i<143;i++)
    {
        int x;
        cin>>x;
        ReceiveA(x);
    }
    vector<int>ans=Answer();
    for(int i=0;i<n;i++)cout<<ans[i]<<endl;
}
#endif // SKY
#include<bits/stdc++.h>

#ifndef SKY
#include "Baijan.h"
#endif // SKY

using namespace std;
#define N 2010
#define ll long long
#define ii pair<int,int>
#define fs first
#define sc second
#define pb push_back

int n,dp[N],ktr[N];
vector<ii>g[N];

#ifdef SKY
void SendB(bool y)
{
    cout<<y<<endl;
}
#endif // SKY

void InitB(int cc, int A, vector<int> U, vector<int> V,  vector<int> C)
{
    n=cc;
    for(int i=0;i<11;i++)
        SendB((A>>i)&1);
    for(int i=0;i<A;i++)
    {
        int u=U[i],v=V[i],L=C[i];
        g[u].pb({L,v});
        g[v].pb({L,u});
        for(int i=0;i<11;i++)
            SendB((u>>i)&1);
        for(int i=0;i<11;i++)
            SendB((v>>i)&1);
        for(int i=0;i<11;i++)
            SendB((L>>i)&1);
        //cout<<u<<" "<<v<<" "<<L<<endl;
    }
    /*priority_queue<ii>s;
    memset(dp,0x3f3f,sizeof(dp));
    dp[0]=0;
    s.push({0,0});
    while(!s.empty())
    {
        ii cc=s.top();
        s.pop();
        int u=cc.sc,L=-cc.fs;
        if(ktr[u]==1)
            continue;
        ktr[u]=0;
        for(auto v:g[u])
            if(dp[v.sc]>L+v.fs)
            {
                dp[v.sc]=L+v.fs;
                s.push({-dp[v.sc],v.sc});
            }
    }*/
}

void ReceiveB(bool x)
{
}

#ifdef SKY
int main()
{
    freopen("Baijan.inp","r",stdin);
    freopen("Baijan.out","w",stdout);
    int n,A;
    vector<int>U,V,C;
    cin>>n>>A;
    for(int i=0;i<A;i++)
    {
        int u,v,c;
        cin>>u>>v>>c;
        U.pb(u);
        V.pb(v);
        C.pb(c);
    }
    InitB(n,A,U,V,C);
}
#endif // SKY

Compilation message

Azer.cpp: In function 'std::vector<int> Answer()':
Azer.cpp:81:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   81 |   for(int i=0;i<n;i++)
      |   ^~~
Azer.cpp:83:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   83 |     return ans;
      |     ^~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 328 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 656 KB Output is correct
2 Correct 241 ms 1012 KB Output is correct
3 Correct 309 ms 1112 KB Output is correct
4 Correct 365 ms 27532 KB Output is correct
5 Correct 142 ms 24080 KB Output is correct
6 Correct 284 ms 800 KB Output is correct
7 Correct 415 ms 24296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 257 ms 876 KB Output is correct
2 Correct 1 ms 656 KB Output is correct
3 Runtime error 1 ms 328 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 162 ms 704 KB Output is correct
2 Correct 225 ms 788 KB Output is correct
3 Runtime error 31 ms 6604 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 162 ms 704 KB Output is correct
2 Correct 225 ms 788 KB Output is correct
3 Runtime error 31 ms 6604 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 162 ms 704 KB Output is correct
2 Correct 225 ms 788 KB Output is correct
3 Runtime error 31 ms 6604 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 328 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -