제출 #27121

#제출 시각아이디문제언어결과실행 시간메모리
27121samir_droubiPort Facility (JOI17_port_facility)C++14
22 / 100
3349 ms818728 KiB
#include <bits/stdc++.h> using namespace std; int n; const int mxn=(1e6)+5; pair<int,int>a[mxn]; int mod=(1e9)+7; map<int,int>in; vector<int>gr[mxn]; int vis[mxn]; int ans=1; queue<int>q; void bfs() { while(!q.empty()) { int v=q.front(); q.pop(); for(int i=0;i<gr[v].size();++i) { int u=gr[v][i]; if(vis[v]==vis[u]) ans=0; if(vis[u]==-1) { vis[u]=1-vis[v]; q.push(u); } } } } int main() { memset(vis,-1,sizeof vis); scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d%d",&a[i].first,&a[i].second); sort(a+1,a+n+1); for(int i=1;i<=n;++i) { map<int,int>::iterator it=in.lower_bound(a[i].first); for(it;it!=in.end()&&(it->first)<a[i].second;++it) { gr[i].push_back(it->second); gr[it->second].push_back(i); } in[a[i].second]=i; } for(int i=1;i<=n;++i) { if(vis[i]!=-1)continue; vis[i]=0; q.push(i); bfs(); ans*=2; ans%=mod; } printf("%d\n",ans); return 0; }

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

port_facility.cpp: In function 'void bfs()':
port_facility.cpp:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<gr[v].size();++i)
                  ^
port_facility.cpp: In function 'int main()':
port_facility.cpp:44:11: warning: statement has no effect [-Wunused-value]
     for(it;it!=in.end()&&(it->first)<a[i].second;++it)
           ^
port_facility.cpp:36:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
port_facility.cpp:38:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&a[i].first,&a[i].second);
                                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...