結果
問題 |
No.488 四角関係
|
ユーザー |
![]() |
提出日時 | 2025-02-22 21:23:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 2,703 bytes |
コンパイル時間 | 2,181 ms |
コンパイル使用メモリ | 195,196 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-22 21:23:24 |
合計ジャッジ時間 | 3,380 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:76:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 76 | printf("%d\n",cnt); | ~^ ~~~ | | | | int long long int | %lld
ソースコード
#include<bits/stdc++.h> #define int long long #define MAXN 105 using namespace std; inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-48; ch=getchar(); } return x*f; } bool check1(bool graph[MAXN][MAXN],int a,int b,int c,int d){ int node[4]={a,b,c,d}; for(int i=0;i<4;i++){ for(int j=i+1;j<4;j++){ for(int k=j+1;k<4;k++){ int u=node[i],v=node[j],w=node[k]; if(graph[u][v] && graph[v][w] && graph[w][u]){ return 1; } } } } return 0; } bool check2(bool graph[MAXN][MAXN],int a,int b,int c,int d){ int node[4]={a,b,c,d}; do{ bool flag=1; for(int i=0;i<4;i++){ int u=node[i],v=node[(i+1)%4]; if(!graph[u][v]){ flag=0; break; } } if(flag) return 1; }while(next_permutation(node,node+4)); return 0; } int n,m; bool graph[MAXN][MAXN]={0}; signed main(){ // freopen("rec.in","r",stdin); // freopen("rec.out","w",stdout); n=read();m=read(); for(int i=0;i<m;i++){ int u,v; u=read();v=read(); graph[u][v]=1; graph[v][u]=1; } int cnt=0; for(int a=0;a<n;a++){ for(int b=a+1;b<n;b++){ for(int c=b+1;c<n;c++){ for(int d=c+1;d<n;d++){ if(!check1(graph,a,b,c,d) && check2(graph,a,b,c,d)){ cnt++; } } } } } printf("%d\n",cnt); return 0; } /*?? ?????? ??????????????????????? ???????????????????? ???????????5???????????????????????????????????????????????????????????????????????????????????????????????24????????????????????????????????????????????????????????????????????? ???????????????????? ???????????????????????????????????????????????????????????????????????????????????????????...????????????? ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...???????????????????????????????? ?????????????? ???????????? ????????????? ????????????? ????????? ??? ? ?? ? ??????? ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????????? ????????????????????? ???????????????????? ????????????? ???????????????? ???????????????????????? ????????????????????????? ?????? ?????????????? ???????????? ??????????????????? ???????????? ?????? ????? ??????????? ?????????????? ????? ????? ????? ?????? ??????????????? ?????????? ?????????????? ???????????? ????*/