結果

問題 No.488 四角関係
コンテスト
ユーザー vjudge1
提出日時 2025-02-22 21:23:26
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 766 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,219 ms
コンパイル使用メモリ 202,428 KB
実行使用メモリ 9,276 KB
最終ジャッジ日時 2026-07-05 06:36:11
合計ジャッジ時間 2,201 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         freopen("rec.in","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:19:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         freopen("rec.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
int mp[55][55],ans,n,m,x,y;
bool check(int a,int b,int c,int d){
	if (mp[a][b]+mp[a][c]+mp[a][d]==3) return 0;
	if (mp[a][b]+mp[b][c]+mp[b][d]==3) return 0;
	if (mp[a][c]+mp[b][c]+mp[c][d]==3) return 0;
	if (mp[a][d]+mp[b][d]+mp[c][d]==3) return 0;
	if (mp[a][b]+mp[a][c]+mp[a][d]+mp[b][c]+mp[b][d]+mp[c][d]==4) 
	{
		//cout<<a<<' '<<b<<' '<<c<<' '<<d<<'\n'; 
		return 1;
	}
	return 0;
}
signed main ()
{
	freopen("rec.in","r",stdin);
	freopen("rec.out","w",stdout);
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		cin>>x>>y;
		mp[x][y]++;
		mp[y][x]++;
	}
	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 (check(a,b,c,d)) ans++;
				}
	cout<<ans;
	return 0;
}
0