結果
| 問題 |
No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-09-07 17:07:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 537 ms |
| コンパイル使用メモリ | 44,176 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-07 17:07:56 |
| 合計ジャッジ時間 | 1,740 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:29:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | for (int i = 0; i < n; i++) scanf("%d%d", ls + i, rs + i);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3262.cc: No.3262 豌エ濶イ繧ウ繝シ繝繝シ縺輔s縲√◎縺ョ蝠城。慧蝠城。後〒縺吶h?(1<=d<=N) - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 8;
/* typedef */
/* global variables */
int ls[MAX_N], rs[MAX_N];
int ps[MAX_N];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d%d", ls + i, rs + i);
for (int i = 0; i < n; i++) ps[i] = i;
int cnt = 0;
do {
bool ok = true;
for (int i = 0, px = 0; i < n; i++) {
if (px > rs[ps[i]]) { ok = false; break; }
px = max(px, ls[ps[i]]);
}
if (ok) cnt++;
} while (next_permutation(ps, ps + n));
printf("%d\n", cnt);
return 0;
}
tnakao0123