제출 #430714

#제출 시각아이디문제언어결과실행 시간메모리
430714cpp219Port Facility (JOI17_port_facility)C++14
100 / 100
1712 ms108816 KiB
#pragma GCC optimization "O2" #pragma GCC optimization "unroll-loop" #pragma GCC target ("avx2") #include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; const ll N = 2e6 + 9; const ll inf = 2e9 + 7; const ll mod = 1e9 + 7; typedef pair<ll,ll> LL; LL a[N]; ll n,lab[N]; set<LL> s; ll Find(ll u){ if (lab[u] < 0) return u; return lab[u] = Find(lab[u]); } void Union(ll p,ll q){ ll r = Find(p),s = Find(q); if (r == s) return; if (lab[r] > lab[s]) swap(r,s); lab[r] += lab[s]; lab[s] = r; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define task "tst" if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); //freopen(task".out", "w", stdout); } cin>>n; memset(lab,-1,sizeof(lab)); for (ll i = 1;i <= n;i++) cin>>a[i].fs>>a[i].sc; sort(a + 1,a + n + 1); for (ll i = 1;i <= n;i++){ auto st = s.lower_bound({a[i].fs,0}),en = s.upper_bound({a[i].sc,inf}); if (en != s.begin()){ for (;st != en;st++){ Union(i,st->sc + n); Union(i + n,st->sc); if (Find(st->sc) == Find(prev(en)->sc)) break; } } s.insert({a[i].sc,i}); } for (ll i = 1;i <= n;i++) if (Find(i) == Find(i + n)) return cout<<0,0; ll ans = 1; for (ll i = 1;i <= n;i++) if (Find(i) == i) ans = (ans*2)%mod; cout<<ans; }

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

port_facility.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization "O2"
      | 
port_facility.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
port_facility.cpp: In function 'int main()':
port_facility.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...