QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558395#8934. Challenge NPCYarema#AC ✓25ms5620kbC++201.8kb2024-09-11 15:52:422024-09-11 15:52:43

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 15:52:43]
  • 评测
  • 测评结果:AC
  • 用时:25ms
  • 内存:5620kb
  • [2024-09-11 15:52:42]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;

const int N = 1 << 11;
int n;
VI g[N];

int badSolve()
{
	int mx = 1;
	VI ans(n);
	FOR(i, 0, n)
	{
		VI vals;
		for(int to : g[i])
		{
			if(to > i)
				continue;
			vals.PB(ans[to]);
		}
		VI has(SZ(vals) + 2);
		for(int val : vals)
			if(val < SZ(has))
				has[val] = 1;
		int cur = 1;
		while(has[cur]) cur++;
		ans[i] = cur;
		mx = max(mx, cur);
		
	}
	return mx;
}


int m = 0;
void addEdge(int v, int u)
{
	g[v].PB(u);
	g[u].PB(v);
	m++;
}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int k;
	cin >> k;
	
	int c = 4;
	FOR(i, 0, c)
		FOR(j, 0, i)
			addEdge(i, j);
	addEdge(c, c + 1);
	
	n = c + 2 + 2 * k;
	VI ans(n);
	FOR(i, 0, c)
		ans[i] = i + 1;
	ans[c] = 3;
	ans[c + 1] = 4;

	FOR(i, 0, k)
	{
		FOR(t, 0, 2)
		{
			int v = c + 2 + 2 * i + t;
			FOR(j, 2, c)
				addEdge(v, j);
			addEdge(v, c);
			addEdge(v, c + 1);
			
			FOR(j, 0, i)
				addEdge(c + 2 + 2 * j + (t ^ 1), v);
			ans[v] = t + 1;
		}
    }
	cout << n << " " << m << " " << c << "\n";
	FOR(i, 0, n)
	{
		if(i)
			cout <<  " ";
		cout << ans[i];
	}
	cout << "\n";
	FOR(i, 0, n)
	{
		for(int to : g[i])
		{
			assert(ans[i] != ans[to]);
			if(to < i)
				cout << to + 1 << " " << i + 1 << "\n";
		}
	}
	
	//cerr << n << "\n";
	//cerr << badSolve() << " " << c + k << "\n";
	
	return 0;
}




这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3532kb

input:

1

output:

8 15 4
1 2 3 4 3 4 1 2
1 2
1 3
2 3
1 4
2 4
3 4
5 6
3 7
4 7
5 7
6 7
3 8
4 8
5 8
6 8

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

2

output:

10 25 4
1 2 3 4 3 4 1 2 1 2
1 2
1 3
2 3
1 4
2 4
3 4
5 6
3 7
4 7
5 7
6 7
3 8
4 8
5 8
6 8
3 9
4 9
5 9
6 9
8 9
3 10
4 10
5 10
6 10
7 10

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

3

output:

12 37 4
1 2 3 4 3 4 1 2 1 2 1 2
1 2
1 3
2 3
1 4
2 4
3 4
5 6
3 7
4 7
5 7
6 7
3 8
4 8
5 8
6 8
3 9
4 9
5 9
6 9
8 9
3 10
4 10
5 10
6 10
7 10
3 11
4 11
5 11
6 11
8 11
10 11
3 12
4 12
5 12
6 12
7 12
9 12

result:

ok ok

Test #4:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

4

output:

14 51 4
1 2 3 4 3 4 1 2 1 2 1 2 1 2
1 2
1 3
2 3
1 4
2 4
3 4
5 6
3 7
4 7
5 7
6 7
3 8
4 8
5 8
6 8
3 9
4 9
5 9
6 9
8 9
3 10
4 10
5 10
6 10
7 10
3 11
4 11
5 11
6 11
8 11
10 11
3 12
4 12
5 12
6 12
7 12
9 12
3 13
4 13
5 13
6 13
8 13
10 13
12 13
3 14
4 14
5 14
6 14
7 14
9 14
11 14

result:

ok ok

Test #5:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

5

output:

16 67 4
1 2 3 4 3 4 1 2 1 2 1 2 1 2 1 2
1 2
1 3
2 3
1 4
2 4
3 4
5 6
3 7
4 7
5 7
6 7
3 8
4 8
5 8
6 8
3 9
4 9
5 9
6 9
8 9
3 10
4 10
5 10
6 10
7 10
3 11
4 11
5 11
6 11
8 11
10 11
3 12
4 12
5 12
6 12
7 12
9 12
3 13
4 13
5 13
6 13
8 13
10 13
12 13
3 14
4 14
5 14
6 14
7 14
9 14
11 14
3 15
4 15
5 15
6 15
8...

result:

ok ok

Test #6:

score: 0
Accepted
time: 18ms
memory: 5120kb

input:

433

output:

872 190527 4
1 2 3 4 3 4 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2...

result:

ok ok

Test #7:

score: 0
Accepted
time: 20ms
memory: 5448kb

input:

500

output:

1006 253507 4
1 2 3 4 3 4 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ...

result:

ok ok

Test #8:

score: 0
Accepted
time: 25ms
memory: 5620kb

input:

499

output:

1004 252501 4
1 2 3 4 3 4 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ...

result:

ok ok

Test #9:

score: 0
Accepted
time: 20ms
memory: 5296kb

input:

457

output:

920 212055 4
1 2 3 4 3 4 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2...

result:

ok ok

Test #10:

score: 0
Accepted
time: 12ms
memory: 5564kb

input:

497

output:

1000 250495 4
1 2 3 4 3 4 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ...

result:

ok ok

Extra Test:

score: 0
Extra Test Passed