제출 #525650

#제출 시각아이디문제언어결과실행 시간메모리
525650idasRegions (IOI09_regions)C++11
30 / 100
1000 ms26152 KiB
#include <bits/stdc++.h> #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define TSTS int ttt; cin >> ttt; while(ttt--) solve() #define all(x) (x).begin(), (x).end() #define le(vec) vec[vec.size()-1] #define sz(x) ((int)((x).size())) #define pb push_back #define s second #define f first using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef map<int, int> mii; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; const int INF=1e9, MOD=1e9+7, mod=998244353; const ll LINF=1e18; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int N=2e5+10, R=510; int n, r, q, up[R], gr[N], pre[R][R]; vi ad[N]; void dfs(int u) { FOR(j, 1, r+1) { pre[j][gr[u]]+=up[j]; } up[gr[u]]++; for(auto x : ad[u]){ dfs(x); } up[gr[u]]--; } int main() { setIO(); cin >> n >> r >> q; cin >> gr[0]; FOR(i, 1, n) { int s; cin >> s >> gr[i]; ad[s-1].pb(i); } dfs(0); while(q--){ int e1, e2; cin >> e1 >> e2; cout << pre[e1][e2] << endl; } }

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

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