# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
341181 | beksultan04 | 결혼 문제 (IZhO14_marriage) | C++14 | 1599 ms | 5612 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
const int N = 1e5+12;
const ll INF=1e9+7;
vector <int> g[N],v;
int m,n,ans,l;
bool vis[N],bb[1001][1001];
int rec(int x,int mn,int mx){
if (x > m){
int ans=0;
if (bb[mn][mx] == 0)ans=1;
bb[mn][mx] = 1;
ret ans;
}
int i,ans=0;
for (i=0;i<g[x].size();++i){
if (vis[g[x][i]] == 0){
vis[g[x][i]]=1;
v.pb(g[x][i]);
ans += rec(x+1,min(mn,g[x][i]),max(mx,g[x][i]));
v.pop_back();
vis[g[x][i]]=0;
}
}
ret ans;
}
main(){
int i,k,j,cnt=0;
scan3(n,m,k)
while (k-- ){
int x,y;
scan2(x,y)
g[y].pb(x);
}
cout <<rec(1,INF,0);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |