제출 #567595

#제출 시각아이디문제언어결과실행 시간메모리
567595birthdaycakeBitaro’s Party (JOI18_bitaro)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define endl '\n' #define int long long #define mod 1000000007 #define boost ios_base::sync_with_stdio(false), cin.tie(NULL); using namespace std; const int sqt = 70; vector<int>adj[200001],radj[200001]; int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71]; signed main(){ boost; int n,m,q; cin >> n >> m >> q; for(int i = 0; i < m; i++){ int a,b; cin >> a >> b; adj[a].push_back(b); radj[b].push_back(a); } for(int i = 1; i <= n; i++){ vector<pair<int,int>>ds; ds.push_back({0,i}); for(auto s:radj[i]){ ds.push_back({1,s}); for(int j = 1; j <= sz[s]; j++){ ds.push_back({dis[s][j] + 1, c[s][j]}); } } sort(ds.begin(), ds.end(), greater<pair<int,int>>()); set<int>x; for(int j = 0; j < ds.size(); j++){ if(x.count(ds[j].second)) continue; dis[i][++sz[i]] = ds[j].first; c[i][sz[i]] = ds[j].second; x.insert(ds[j].second); } } while(q--){ int t,y, ans = -1; cin >> t >> y; set<int>f; for(int i = 0; i < y; i++){ int x; cin >> x; f.insert(x); } if(y > sqt){ for(int i = 1; i <= t; i++){ if(f.count(i)) dist[i] = -1e18; else dist[i] = 0; for(auto x:radj[i]){ dist[i] = max(dist[i], dist[x] + 1); } if(!f.count(i)) ans = max(ans,dist[t]); } }else{ for(int j = 1; j <= sz[t]; j++){ if(!f.count(c[t][j])){ ans = dis[t][j]; break; } } } cout << ans << endl; } return 0; } #include<bits/stdc++.h> #define endl '\n' #define int long long #define mod 1000000007 #define boost ios_base::sync_with_stdio(false), cin.tie(NULL); using namespace std; const int sqt = 70; vector<int>adj[200001],radj[200001]; int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71]; signed main(){ boost; int n,m,q; cin >> n >> m >> q; for(int i = 0; i < m; i++){ int a,b; cin >> a >> b; adj[a].push_back(b); radj[b].push_back(a); } for(int i = 1; i <= n; i++){ vector<pair<int,int>>ds; ds.push_back({0,i}); for(auto s:radj[i]){ ds.push_back({1,s}); for(int j = 1; j <= sz[s]; j++){ ds.push_back({dis[s][j] + 1, c[s][j]}); } } sort(ds.begin(), ds.end(), greater<pair<int,int>>()); set<int>x; for(int j = 0; j < ds.size(); j++){ if(x.count(ds[j].second)) continue; dis[i][++sz[i]] = ds[j].first; c[i][sz[i]] = ds[j].second; x.insert(ds[j].second); } } while(q--){ int t,y, ans = -1; cin >> t >> y; set<int>f; for(int i = 0; i < y; i++){ int x; cin >> x; f.insert(x); } if(y > sqt){ for(int i = 1; i <= t; i++){ if(f.count(i)) dist[i] = -1e18; else dist[i] = 0; for(auto x:radj[i]){ dist[i] = max(dist[i], dist[x] + 1); } if(!f.count(i)) ans = max(ans,dist[t]); } }else{ for(int j = 1; j <= sz[t]; j++){ if(!f.count(c[t][j])){ ans = dis[t][j]; break; } } } cout << ans << endl; } return 0; }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:37:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int j = 0; j < ds.size(); j++){
      |                        ~~^~~~~~~~~~~
bitaro.cpp: At global scope:
bitaro.cpp:85:11: error: redefinition of 'const long long int sqt'
   85 | const int sqt = 70;
      |           ^~~
bitaro.cpp:9:11: note: 'const long long int sqt' previously defined here
    9 | const int sqt = 70;
      |           ^~~
bitaro.cpp:88:12: error: redefinition of 'std::vector<long long int> adj [200001]'
   88 | vector<int>adj[200001],radj[200001];
      |            ^~~
bitaro.cpp:12:12: note: 'std::vector<long long int> adj [200001]' previously declared here
   12 | vector<int>adj[200001],radj[200001];
      |            ^~~
bitaro.cpp:88:24: error: redefinition of 'std::vector<long long int> radj [200001]'
   88 | vector<int>adj[200001],radj[200001];
      |                        ^~~~
bitaro.cpp:12:24: note: 'std::vector<long long int> radj [200001]' previously declared here
   12 | vector<int>adj[200001],radj[200001];
      |                        ^~~~
bitaro.cpp:90:5: error: redefinition of 'long long int no [200001]'
   90 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |     ^~
bitaro.cpp:14:5: note: 'long long int no [200001]' previously declared here
   14 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |     ^~
bitaro.cpp:90:16: error: redefinition of 'long long int dist [200001]'
   90 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |                ^~~~
bitaro.cpp:14:16: note: 'long long int dist [200001]' previously declared here
   14 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |                ^~~~
bitaro.cpp:90:29: error: redefinition of 'long long int sz [200001]'
   90 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |                             ^~
bitaro.cpp:14:29: note: 'long long int sz [200001]' previously declared here
   14 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |                             ^~
bitaro.cpp:90:40: error: redefinition of 'long long int dis [200001][71]'
   90 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |                                        ^~~
bitaro.cpp:14:40: note: 'long long int dis [200001][71]' previously declared here
   14 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |                                        ^~~
bitaro.cpp:90:56: error: redefinition of 'long long int c [200001][71]'
   90 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |                                                        ^
bitaro.cpp:14:56: note: 'long long int c [200001][71]' previously declared here
   14 | int no[200001],dist[200001],sz[200001],dis[200001][71],c[200001][71];
      |                                                        ^
bitaro.cpp:91:8: error: redefinition of 'int main()'
   91 | signed main(){
      |        ^~~~
bitaro.cpp:15:8: note: 'int main()' previously defined here
   15 | signed main(){
      |        ^~~~
bitaro.cpp: In function 'int main()':
bitaro.cpp:113:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |         for(int j = 0; j < ds.size(); j++){
      |                        ~~^~~~~~~~~~~