結果

問題 No.2563 色ごとのグループ
ユーザー SotaSota
提出日時 2024-02-14 12:33:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,465 bytes
コンパイル時間 1,560 ms
コンパイル使用メモリ 117,636 KB
実行使用メモリ 813,664 KB
最終ジャッジ日時 2024-02-14 12:33:52
合計ジャッジ時間 6,821 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,676 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 4 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 WA -
testcase_20 AC 45 ms
40,320 KB
testcase_21 AC 18 ms
12,288 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>		//cin, cout
#include <vector>		//vector
#include <algorithm>	//sort,min,max,count
#include <string>		//string,getline, to_string
#include <cstdlib>		//abs(int)
#include <utility>		//swap, pair
#include <tuple>        //tuple
#include <deque>		//deque
#include <climits>		//INT_MAX
#include <bitset>		//bitset
#include <cmath>		//sqrt, ceil. M_PI, pow, sin
#include <ios>			//fixed
#include <iomanip>		//setprecision
#include <sstream>		//stringstream
#include <numeric>		//gcd, assumlate
#include <random>		//randam_device
#include <limits>		//numeric_limits

using namespace std;
constexpr long long int D_MOD = 1000000007;

int main() {

	int N, M;
	cin >> N >> M;

	vector<vector<int>> A(N);
	vector<vector<bool>> B(N, vector<bool>(N));

	int temp1, temp2;

	for (int i = 0; i < N; i++) {
		cin >> temp1;
		A.at(temp1 - 1).push_back(i + 1);
	}

	sort(A.rbegin(), A.rend());

	for (int i = 0; i < M; i++) {
		cin >> temp1 >> temp2;
		B.at(temp1 - 1).at(temp2 - 1) = true;
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (A.at(i).size() == 1) {
			continue;
		}
		else if (A.at(i).size() == 0) {
			break;
		}
		else {
			ans += A.at(i).size() - 1;
			for (unsigned int j = 0; j < A.at(i).size() - 1; j++) {
				for (unsigned int k = j + 1; k < A.at(i).size(); k++) {
					if (B.at(A.at(i).at(j) - 1).at(A.at(i).at(k) - 1) == true) {
						ans--;
					}
				}
			}
		}
	}

	cout << ans << endl;

	return 0;

}
0