Submission #313918

#TimeUsernameProblemLanguageResultExecution timeMemory
313918phathnvWand (COCI19_wand)C++11
70 / 70
128 ms4856 KiB
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "WAND" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 100001; int n, m; vector <int> adj[N]; bool vst[N]; void readInput(){ cin >> n >> m; for(int i = 1; i <= m; i++){ int u, v; cin >> u >> v; adj[v].push_back(u); } } void dfs(int u){ for(int v : adj[u]){ if (vst[v]) continue; vst[v] = 1; dfs(v); } } void solve(){ dfs(1); if (adj[1].empty()) vst[1] = 1; for(int i = 1; i <= n; i++) cout << (vst[i]? '1' : '0'); } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }

Compilation message (stderr)

wand.cpp: In function 'int main()':
wand.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   47 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
wand.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   48 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...