結果

問題 No.742 にゃんにゃんにゃん 猫の挨拶
ユーザー okok
提出日時 2018-10-05 23:01:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 984 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 55,260 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 18:00:27
合計ジャッジ時間 2,123 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_V 10

signed main(){
	int temp[3][MAX_V] = {}, N, M, count = 0;
	
	cin>>N;
	
	for(int i = 1; i <= N; i++){
		cin>>M;
		if(M > i){
			temp[0][i]++;
			temp[0][M]--;
		}else if(M < i){
			temp[1][i+1]--;
			temp[1][M+1]++;
		} else temp[2][M]++;
	}
	for(int j = 1; j < MAX_V; j++){
		temp[0][j] += temp[0][j-1];
		temp[1][j] += temp[1][j-1];
	}
	for(int j = 1; j < MAX_V; j++){
		int f = (temp[0][j]?1:0) + (temp[1][j]?1:0) + (temp[2][j]?1:0);
		//if(temp[0][j] || temp[1][j] || temp[2][j])
		//	if(!((!temp[0][j]&&!temp[1][j])||(!temp[1][j]&&!temp[2][j])||(!temp[2][j]&&!temp[0][j])))
		// if(f >= 2)
			count += temp[0][j]*temp[1][j] + temp[1][j]*temp[2][j] + temp[2][j]*temp[0][j];
		
		//cout<<temp[0][j]<<" "<<temp[1][j]<<" "<<temp[2][j]<<endl;
		
	}
	
	cout<<count<<endl;
	
	
	
	return 0;
}
0