제출 #127173

#제출 시각아이디문제언어결과실행 시간메모리
127173baluteshihPort Facility (JOI17_port_facility)C++14
0 / 100
27 ms27768 KiB
#include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define MP make_pair #define F first #define S second #define MEM(i,j) memset(i,j,sizeof i) #define ALL(v) v.begin(),v.end() #define ET cout << "\n" #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MOD=1e9+7; vector<int> G[1000005]; map<int,int> mp; pii seg[1000005]; int color[1000005]; bool dfs(int u,int c) { color[u]=c; for(int i:G[u]) if(!~color[i]&&!dfs(i,c^1)) return 0; else if(color[i]==color[u]) return 0; return 1; } int main() {jizz int n,cnt=0,flag=1,ans=1; cin >> n; for(int i=0;i<n;++i) cin >> seg[i].F >> seg[i].S; sort(seg,seg+n),MEM(color,-1); for(int i=0;i<n&&flag;++i) { int w[2]={}; for(int j=0;j<i;++j) if(seg[j].S>seg[i].F&&seg[i].S>seg[j].S) if(~color[j]) w[color[j]]=1; if(w[0]&&w[1]) flag=0; else if(w[0]||w[1]) { color[i]=w[0]?1:0; for(int j=0;j<i;++j) if(seg[j].S>seg[i].F&&seg[i].S>seg[j].S) if(!~color[j]) color[j]=color[i]^1; } else { ans=ans*2%MOD; color[i]=0; for(int j=0;j<i;++j) if(seg[j].S>seg[i].F&&seg[i].S>seg[j].S) color[j]=1; } } if(flag) cout << ans << "\n"; else cout << "0\n"; }

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

port_facility.cpp: In function 'int main()':
port_facility.cpp:35:8: warning: unused variable 'cnt' [-Wunused-variable]
  int n,cnt=0,flag=1,ans=1;
        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...