제출 #227273

#제출 시각아이디문제언어결과실행 시간메모리
227273stefanbalaz2Port Facility (JOI17_port_facility)C++14
0 / 100
4 ms384 KiB
/* */ #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back ///#define ll long long typedef pair<int,int> pii; const int maxn=1e6+10; int mod=1e9+7,e; int n,kolko,rez,grane,sz[maxn],cc,levi[maxn]; pii niz[2*maxn],p[maxn]; void reset(){ for(int i=1;i<=n;i++){ p[i]={i,0}; sz[i]=1; } cc=n; } pii root(int x){ if(p[x].ff==x)return p[x]; else{ pii pom=root(p[x].ff); p[x]={pom.ff,p[x].ss^pom.ss}; return p[x]; } } int join(int x,int y){ pii rx=root(x); pii ry=root(y); if(rx.ff==ry.ff){ if(rx.ss=ry.ss)return 1; else return 0; } if(sz[rx.ff]<sz[ry.ff])swap(rx,ry),swap(x,y); cc--; p[ry.ff]={rx.ff,(rx.ss^ry.ss^1)}; sz[rx.ff]+=sz[ry.ff]; return 0; } int main(){ ///freopen("test.txt","r",stdin); clock_t start=clock(); scanf("%d",&n); reset(); for(int i=1;i<=n;i++){ int a,b; scanf("%d %d",&a,&b); niz[a]={i,1}; niz[b]={i,-1}; levi[i]=a; } set<pii>st; for(int i=1;i<=2*n;i++){ if(niz[i].ss>0)st.insert({i,niz[i].ff}); else{ int id=niz[i].ff; int lb=levi[id]; set<pii>::iterator it=st.find({levi[id],id}); it++; ///printf("%d AAAAA\n",id); for(;it!=st.end();it++){ int id2=(*it).ff; ///printf("%d AFSAFSAFSAFAS\n",id2); if(join(id,id2)){ printf("0\n"); return 10; } } st.erase(st.find({lb,id})); /* clock_t sad=clock(); if((double)(sad-start)/CLOCKS_PER_SEC>5){ printf("0\n"); return 0; }*/ } } rez=1; for(int i=1;i<=cc;i++){ rez+=rez; if(rez>=mod)rez-=mod; } printf("%d\n",rez); return 0; }

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

port_facility.cpp: In function 'int join(int, int)':
port_facility.cpp:39:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
         if(rx.ss=ry.ss)return 1;
                 ^
port_facility.cpp: In function 'int main()':
port_facility.cpp:55:13: warning: unused variable 'start' [-Wunused-variable]
     clock_t start=clock();
             ^~~~~
port_facility.cpp:57:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
port_facility.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&a,&b);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...