답안 #425088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
425088 2021-06-12T13:11:37 Z Theo830 장난감 기차 (IOI17_train) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<int,int>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "train.h"
ll comp[5005];
bool v[5005] = {0};
ll posoi[5005] = {0};
vector<vll>adj;
vll nodes;
vll epia;
void solve(ll idx,bool V){
    if(V){
        nodes.pb(idx);
    }
    else{
        epia.pb(idx);
    }
    for(auto x:adj[idx]){
        if(!v[x]){
            v[x] = 1;
            solve(x,V);
        }
    }
}
bool v2[n] = {0};
vector<vll>adj2;
void dfs(ll idx){
    v[idx] = 1;
    for(auto x:adj2[idx]){
        if(!v[x]){
            dfs(x);
        }
    }
}
vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	vector<int> res(a.size());
	ll n = a.size();
	ll m = u.size();
	adj.assign(n+5,vll());
	f(i,0,m){
        adj[u[i]].pb(v[i]);
	}
	f(i,0,n){
        if(!v[i]){
            v[i] = 1;
            solve(i,1);
        }
	}
	reverse(all(nodes));
	memset(v,0,sizeof v);
	for(auto x:nodes){
        if(!v[x]){
            v[x] = 1;
            epia.clear();
            solve(x,0);
            for(auto y:epia){
                comp[y] = x;
            }
        }
	}
	bool ok[n] = {0};
	bool self[n] = {0};
	f(i,0,n){
	    posoi[comp[i]]++;
	    ok[comp[i]] |= r[i];
        for(auto x:adj[i]){
            adj[comp[i]].pb(comp[x]);
            if(x == i){
                self[comp[i]] = 1;
            }
        }
	}
	f(i,0,n){
	    if(posoi[comp[i]] == 1){
            dfs(comp[i]);
	    }
        res[i] = 0;
        f(j,0,n){
            if((v[j] && ok[j]) && (posoi[j] > 1 || self[j])){
                res[i] = 1;
            }
        }
	}
	return res;
}
/*
int main(){
	int n, m;
	assert(2 == scanf("%d %d", &n, &m));

	vector<int> a(n), r(n), u(m), v(m);

	for(int i = 0; i < n; i++)
		assert(1 == scanf("%d", &a[i]));

	for(int i = 0; i < n; i++)
		assert(1 == scanf("%d", &r[i]));

	for(int i = 0; i < m; i++)
		assert(2 == scanf("%d %d", &u[i], &v[i]));

	vector<int> res = who_wins(a, r, u, v);

	for(int i = 0; i < (int)res.size(); i++)
		printf(i ? " %d" : "%d", res[i]);
	printf("\n");

	return 0;
}
*/

Compilation message

train.cpp:46:9: error: 'n' was not declared in this scope
   46 | bool v2[n] = {0};
      |         ^
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:71:9: error: cannot convert 'std::vector<int>' to 'void*'
   71 |  memset(v,0,sizeof v);
      |         ^
      |         |
      |         std::vector<int>
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from train.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~