제출 #1085360

#제출 시각아이디문제언어결과실행 시간메모리
1085360IUA_Hasin9월 (APIO24_september)C++17
100 / 100
371 ms39232 KiB
#include "september.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long using namespace std; using namespace __gnu_pbds; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { ll deg[N], vis[N]; for(int i=0; i<N; i++){ deg[i] = 0; vis[i] = 0; } for(int i=1; i<F.size(); i++){ ll a = F[i]; deg[i]++; deg[a]++; } if(M==0){ ll ans = 0; set<ll> s; for(int i=0; i<S.size(); i++){ for(int j=0; j<S[i].size(); j++){ ll a = S[i][j]; ll parnt = F[a]; deg[a]--; deg[parnt]--; //cout << deg[a] << " " << deg[parnt] << endl; auto it = s.find(parnt); if(deg[a]!=0){ s.insert(a); } if(it!=s.end()){ if(deg[parnt]==0){ s.erase(it); } } if(s.size()==0){ ans++; } for(auto u : s){ cout << u << " "; } //cout << i << " " << 59; cout<<endl; } } return ans; } else { set<ll> world; set<ll> s[M]; set<ll> check; ll ans = 0; for(int i=0; i<S[0].size(); i++){ for(int j=0; j<M; j++){ ll a = S[j][i]; ll parnt = F[a]; world.insert(a); s[j].insert(a); if(vis[a]==0){ deg[a]--; deg[parnt]--; auto it = check.find(parnt); if(deg[a]!=0){ check.insert(a); } if(it!=check.end()){ if(deg[parnt]==0){ check.erase(it); } } vis[a] = 1; } // for(auto u : check){ // cout << u << " "; // } // cout<<endl; } ll status = 1; ll siz = world.size(); for(int j=0; j<M; j++){ ll a = s[j].size(); if(a!=siz){ status = -1; break; } } if(status==1 && check.size()==0){ ans++; } // cout<<endl; // for(auto u : check){ // cout << u << " "; // } // cout<<endl; } return ans; } }

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

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i=1; i<F.size(); i++){
      |               ~^~~~~~~~~
september.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for(int i=0; i<S.size(); i++){
      |                ~^~~~~~~~~
september.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for(int j=0; j<S[i].size(); j++){
      |                 ~^~~~~~~~~~~~
september.cpp:76:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |   for(int i=0; i<S[0].size(); i++){
      |                ~^~~~~~~~~~~~
#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...