Submission #1135465

#TimeUsernameProblemLanguageResultExecution timeMemory
1135465irmuunRail (IOI14_rail)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "rail.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

void findLocation(int N, int first, int location[], int stype[]){
    location[0]=first;
    stype[0]=1;
    if(N==1){
        return;
    }
    int dist[N][N];
    for(int i=0;i<N;i++){
        dist[i][i]=0;
        for(int j=i+1;j<N;j++){
            dist[i][j]=getDistance(i,j);
            dist[j][i]=dist[i][j];
        }
    }
    vector<int>g[N];
    vector<pair<int,int>>v;
    for(int i=0;i<N;i++){
        int mn=1e9,idx=-1;
        for(int j=0;j<N;j++){
            if(j==i) continue;
            if(dist[i][j]<mn){
                mn=dist[i][j];
                idx=j;
            }
        }
        g[i].pb(idx);
        g[idx].pb(i);
        v.pb({i,idx});
    }
    int D=-1;
    for(auto p:v){
    	int x=p.ff,y=p.ss;
        if(x==0||y==0){
            if(x==0){
                D=y;
            }
            if(x==0) swap(x,y);
            location[x]=first+dist[x][y];
            stype[x]=2;
        }
    }
    vector<bool>used(N,false);
    queue<int>q;
    q.push(0);
    used[0]=true;
    while(!q.empty()){
        int x=q.front();
        q.pop();
        for(int y:g[x]){
            if(!used[y]){
                used[y]=true;
                if(stype[x]==1){
                    location[y]=location[x]+dist[x][y];
                    stype[y]=2;
                }
                else{
                    location[y]=location[x]-dist[x][y];
                    stype[y]=1;
                }
                q.push(y);
            }
        }
    }
    for(auto p:v){
    	int x=p.ff,y=p.ss;
        if(usde[x]==true||used[y]==true) continue;
        if(dist[x][0]==dist[x][D]+dist[D][0]){//Left
            if(dist[x][D]>dist[y][D]){
                swap(x,y);//x then y
            }
            location[x]=location[D]-dist[D][x];
            location[y]=location[x]+dist[x][y];
            stype[x]=1;
            stype[y]=2;
        }
        else{//Right
            if(dist[x][0]>dist[y][0]){
                swap(x,y);//y then x
            }
            location[x]=location[0]+dist[0][x];
            location[y]=location[x]-dist[x][y];
            stype[x]=2;
            stype[y]=1;
        }
    }
}

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:78:12: error: 'usde' was not declared in this scope; did you mean 'used'?
   78 |         if(usde[x]==true||used[y]==true) continue;
      |            ^~~~
      |            used