提出 #66813879


ソースコード 拡げる

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;
const int N = 1 << 10;
int n,m,l[N + 2],r[N + 2],tag[N + 2],tg,p[N + 2];
vector<int> e[N + 2];
bool vis[N + 2];
vector<int> f;
void dfs(int u) {
	if(vis[u]||tag[u]==tg) return ;
	tag[u]=tg;
	f.push_back(u);
	for(auto v : e[u]) dfs(v);
}
void solve(vector<int> V) {
	sort(V.begin(),V.end());
	for(auto i : V) {
		if(vis[i]) continue;
		f.clear();
		++tg;
		dfs(i);
		auto x=f;
		x.erase(x.begin());
		solve(x);
		p[i]=++m;
		vis[i]=1;
	}
}
int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		scanf("%d",&n);
		for(int i=1; i<=n; ++i) scanf("%d%d",&l[i],&r[i]);
		m=0;
		for(int i=1; i<=n; ++i) vis[i]=0;
		for(int i=1; i<=n; ++i)
			for(int j=1; j<=n; ++j)
				if(l[i]<l[j]&&r[j]<r[i])
					e[i].push_back(j);
		vector<int> S;
		for(int i=1; i<=n; ++i) S.push_back(i);
		solve(S);
		for(int i=1; i<=n; ++i) printf("%d%c",p[i]," \n"[i==n]);
		for(int i=1; i<=n; ++i) e[i].clear();
	}
	return 0;
}

提出情報

提出日時
問題 C - Movie Theater
ユーザ lnw143
言語 C++ 17 (gcc 12.2)
得点 700
コード長 1061 Byte
結果 AC
実行時間 45 ms
メモリ 4996 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         scanf("%d",&T);
      |         ~~~~~^~~~~~~~~
Main.cpp:36:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |                 scanf("%d",&n);
      |                 ~~~~~^~~~~~~~~
Main.cpp:37:46: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |                 for(int i=1; i<=n; ++i) scanf("%d%d",&l[i],&r[i]);
      |                                         ~~~~~^~~~~~~~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 700 / 700
結果
AC × 1
AC × 27
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 03_random_00.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt, 03_random_13.txt, 03_random_14.txt, 03_random_15.txt, 03_random_16.txt, 03_random_17.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3136 KiB
01_small_00.txt AC 1 ms 3264 KiB
01_small_01.txt AC 1 ms 3300 KiB
01_small_02.txt AC 1 ms 3296 KiB
02_handmade_00.txt AC 1 ms 3284 KiB
02_handmade_01.txt AC 2 ms 3296 KiB
02_handmade_02.txt AC 45 ms 4996 KiB
02_handmade_03.txt AC 2 ms 3968 KiB
02_handmade_04.txt AC 4 ms 3740 KiB
03_random_00.txt AC 1 ms 3064 KiB
03_random_01.txt AC 1 ms 3304 KiB
03_random_02.txt AC 1 ms 3220 KiB
03_random_03.txt AC 1 ms 3036 KiB
03_random_04.txt AC 1 ms 3228 KiB
03_random_05.txt AC 1 ms 3260 KiB
03_random_06.txt AC 1 ms 3320 KiB
03_random_07.txt AC 2 ms 3236 KiB
03_random_08.txt AC 3 ms 3448 KiB
03_random_09.txt AC 2 ms 3552 KiB
03_random_10.txt AC 3 ms 3556 KiB
03_random_11.txt AC 2 ms 3572 KiB
03_random_12.txt AC 2 ms 3376 KiB
03_random_13.txt AC 2 ms 3512 KiB
03_random_14.txt AC 2 ms 3308 KiB
03_random_15.txt AC 2 ms 3308 KiB
03_random_16.txt AC 2 ms 3328 KiB
03_random_17.txt AC 2 ms 3292 KiB