QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114717 | #6663. 회의실 2 | Crysfly | 3 | 787ms | 3780kb | C++17 | 2.7kb | 2023-06-23 09:20:10 | 2023-06-23 09:20:12 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ull unsigned long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 1000000007
struct modint{
int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
friend modint operator +(modint a,modint b){return a+=b;}
friend modint operator -(modint a,modint b){return a-=b;}
friend modint operator *(modint a,modint b){return a*=b;}
friend modint operator /(modint a,modint b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,int b){return a.x==b;}
friend bool operator !=(modint a,int b){return a.x!=b;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 2005
#define inf 0x3f3f3f3f
int n,l[maxn],r[maxn],p[maxn];
int res1,res2;
int fa[maxn];
int gf(int x){
while(x!=fa[x])x=fa[x]=fa[fa[x]];
return x;
}
bool inter(int u,int v){
if(l[u]>l[v])swap(u,v);
return l[v]<r[u];
}
void chk(){
int res=0,now=0;
For(i,1,n){
++now;
int u=p[i];
fa[u]=u;
For(j,1,i-1){
int v=p[j];
if(inter(u,v) && gf(u)!=gf(v)) fa[gf(u)]=gf(v),--now;
}
res+=now;
}
if(res<res1)res1=res,res2=1;
else if(res==res1)res2++;
}
int count_removals(vi S,vi SS){
n=S.size();
For(i,1,n)l[i]=S[i-1],r[i]=SS[i-1];
For(i,1,n)p[i]=i;
res1=inf;
do{
chk();
}while(next_permutation(p+1,p+n+1));
return res2;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 3
Accepted
Test #1:
score: 3
Accepted
time: 1ms
memory: 3692kb
input:
2 1 4 2 3
output:
Meeting 2 - By moonrabbit2 My answer is: 2
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 688ms
memory: 3692kb
input:
10 1 20 2 9 3 4 5 8 6 7 10 17 11 16 12 13 14 15 18 19
output:
Meeting 2 - By moonrabbit2 My answer is: 845040
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 612ms
memory: 3708kb
input:
10 1 20 2 11 3 12 4 13 5 14 6 15 7 16 8 17 9 18 10 19
output:
Meeting 2 - By moonrabbit2 My answer is: 3628800
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
4 1 2 3 4 5 6 7 8
output:
Meeting 2 - By moonrabbit2 My answer is: 24
result:
ok 2 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
2 1 2 3 4
output:
Meeting 2 - By moonrabbit2 My answer is: 2
result:
ok 2 lines
Test #6:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
2 1 3 2 4
output:
Meeting 2 - By moonrabbit2 My answer is: 2
result:
ok 2 lines
Test #7:
score: 0
Accepted
time: 684ms
memory: 3780kb
input:
10 1 5 2 3 4 7 6 11 8 9 10 15 12 13 14 20 16 17 18 19
output:
Meeting 2 - By moonrabbit2 My answer is: 13280
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 755ms
memory: 3692kb
input:
10 1 5 2 9 3 10 4 12 6 14 7 16 8 17 11 18 13 19 15 20
output:
Meeting 2 - By moonrabbit2 My answer is: 1797408
result:
ok 2 lines
Test #9:
score: 0
Accepted
time: 787ms
memory: 3764kb
input:
10 12 16 5 7 10 19 2 3 4 6 17 20 8 11 1 15 14 18 9 13
output:
Meeting 2 - By moonrabbit2 My answer is: 647760
result:
ok 2 lines
Test #10:
score: 0
Accepted
time: 707ms
memory: 3692kb
input:
10 1 20 6 11 7 17 12 19 3 16 10 18 4 8 5 15 2 13 9 14
output:
Meeting 2 - By moonrabbit2 My answer is: 3261600
result:
ok 2 lines
Test #11:
score: 0
Accepted
time: 706ms
memory: 3620kb
input:
10 1 20 11 18 6 14 8 13 7 19 12 16 10 17 5 15 3 9 2 4
output:
Meeting 2 - By moonrabbit2 My answer is: 2193120
result:
ok 2 lines
Test #12:
score: 0
Accepted
time: 766ms
memory: 3696kb
input:
10 1 20 14 15 3 18 4 8 10 16 12 19 2 11 5 7 9 13 6 17
output:
Meeting 2 - By moonrabbit2 My answer is: 2490480
result:
ok 2 lines
Test #13:
score: 0
Accepted
time: 699ms
memory: 3688kb
input:
10 1 20 2 16 10 18 3 11 5 19 9 17 6 7 13 14 4 15 8 12
output:
Meeting 2 - By moonrabbit2 My answer is: 3054720
result:
ok 2 lines
Test #14:
score: 0
Accepted
time: 742ms
memory: 3620kb
input:
10 1 20 2 8 5 9 13 16 4 12 14 15 11 18 7 17 3 19 6 10
output:
Meeting 2 - By moonrabbit2 My answer is: 2432160
result:
ok 2 lines
Test #15:
score: 0
Accepted
time: 734ms
memory: 3616kb
input:
10 1 20 5 16 3 4 6 9 12 15 2 17 18 19 8 10 13 14 7 11
output:
Meeting 2 - By moonrabbit2 My answer is: 1242900
result:
ok 2 lines
Test #16:
score: 0
Accepted
time: 711ms
memory: 3692kb
input:
10 1 20 8 15 10 19 11 17 5 13 6 9 12 18 2 3 7 14 4 16
output:
Meeting 2 - By moonrabbit2 My answer is: 1716480
result:
ok 2 lines
Test #17:
score: 0
Accepted
time: 736ms
memory: 3736kb
input:
10 1 20 4 5 2 3 15 17 8 9 7 19 6 13 14 16 10 18 11 12
output:
Meeting 2 - By moonrabbit2 My answer is: 1035760
result:
ok 2 lines
Test #18:
score: 0
Accepted
time: 633ms
memory: 3736kb
input:
10 1 20 13 16 18 19 2 3 8 10 12 17 4 5 9 11 6 7 14 15
output:
Meeting 2 - By moonrabbit2 My answer is: 770400
result:
ok 2 lines
Test #19:
score: 0
Accepted
time: 69ms
memory: 3692kb
input:
9 1 18 4 6 12 17 7 9 14 15 11 13 10 16 5 8 2 3
output:
Meeting 2 - By moonrabbit2 My answer is: 94080
result:
ok 2 lines
Subtask #2:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Test #20:
score: 0
Time Limit Exceeded
input:
20 31 32 7 8 39 40 25 26 19 20 21 22 9 10 17 18 1 2 23 24 15 16 29 30 5 6 35 36 3 4 11 12 33 34 27 28 13 14 37 38
output:
Unauthorized output
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Time Limit Exceeded
Test #96:
score: 0
Time Limit Exceeded
input:
2000 2245 2246 2189 2190 1681 1682 1005 1006 1367 1368 2797 2798 2407 2408 1511 1512 1441 1442 3795 3796 1835 1836 1747 1748 2941 2942 3435 3436 2095 2096 1631 1632 2737 2738 1653 1654 2637 2638 3823 3824 3491 3492 15 16 325 326 2195 2196 3037 3038 3039 3040 1431 1432 3241 3242 715 716 2909 2910 119...
output:
Unauthorized output
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #120:
score: 0
Time Limit Exceeded
input:
1557 1352 1357 3085 3086 7 154 2861 2866 131 134 14 105 327 338 759 778 357 358 1863 1864 1968 1969 2795 2808 64 71 1299 1300 1215 1216 2048 2053 1750 1751 1957 1958 2598 2599 1817 1822 2699 2722 2583 2588 2005 2100 1334 1335 356 359 882 883 1707 1708 3001 3002 818 821 1102 1103 2968 2969 2788 2789 ...
output:
Unauthorized output
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #143:
score: 0
Time Limit Exceeded
input:
1342 2401 2667 982 2071 494 1558 420 1442 91 681 1002 2088 1268 2277 971 2064 1092 2156 1980 2591 1081 2144 131 852 1011 2091 157 924 1551 2438 1940 2579 477 1530 1902 2569 1245 2261 448 1487 138 883 1511 2415 616 1712 492 1556 1225 2245 476 1529 1077 2140 804 1923 137 882 1387 2342 1222 2243 1824 2...
output:
Unauthorized output
result:
Subtask #7:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%