제출 #1305454

#제출 시각아이디문제언어결과실행 시간메모리
1305454the_commando_xAlkemija (COCI18_alkemija)C++17
80 / 80
33 ms10968 KiB
// #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using pii = pair<int, int>; using vii = vector<pii>; using vvii = vector<vii>; using l = long long; using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>; using pll = pair<l, l>; using vll = vector<pll>; using vvll = vector<vll>; using d = double; using vd = vector<d>; using vvd = vector<vd>; using vvvd = vector<vvd>; using ld = long double; using vld = vector<ld>; using vvld = vector<vld>; using vvvld = vector<vvld>; using vb = vector<bool>; using vvb = vector<vb>; using pbb = pair<bool, bool>; using vbb = vector<pbb>; #define ff first #define ss second #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)(x).size() void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0); if (!name.empty()) { (void)freopen((name + ".in").c_str(), "r", stdin); (void)freopen((name + ".out").c_str(), "w", stdout); } } const ld pi = 3.14159265358979323846; const l LINF = 1e18; const l INF = 1e9; const l MOD = 1e9 + 7; // const l MOD = 998244353; const l MAXN = 2e5 + 5; vvi adj(MAXN); vi vis(MAXN), freq(MAXN); queue<int> q; void solve() { int n, m; cin >> n >> m; for (int i = 1, x; i <= m && cin >> x; ++i) if (!vis[x]) q.push(x), vis[x] = true; int k; cin >> k; for (int i = 1; i <= k; ++i) { int L, R, x; cin >> L >> R; freq[i + n] = L; while (L--) { cin >> x; adj[x].push_back(i + n); } while (R--) { cin >> x; adj[i + n].push_back(x); } } while (q.size()) { int u = q.front(); q.pop(); for (auto v : adj[u]) { if (--freq[v] != 0) continue; for (auto x : adj[v]) if (!vis[x]) q.push(x), vis[x] = true; } } int ans = accumulate(all(vis), 0); vi b; for (int i = 1; i <= n; ++i) if (vis[i]) b.push_back(i); cout << ans << "\n"; for (auto x : b) cout << x << " "; } int main() { setIO(""); #ifndef ONLINE_JUDGE // setIO("filename"); #endif int t = 1; // cin >> t; while (t--) solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

alkemija.cpp: In function 'void setIO(std::string)':
alkemija.cpp:53:22: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         (void)freopen((name + ".in").c_str(), "r", stdin);
      |               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alkemija.cpp:54:22: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         (void)freopen((name + ".out").c_str(), "w", stdout);
      |               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...