QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386887#5108. Prehistoric ProgramsPetroTarnavskyi#WA 0ms7844kbC++202.5kb2024-04-11 21:03:542024-04-11 21:03:55

Judging History

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

  • [2024-04-11 21:03:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7844kb
  • [2024-04-11 21:03:54]
  • 提交

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 pair<int, int> PII;
typedef double db;


const int N = 47;
PII w[N];

const int N2 = 1047;
int a[N2][N2];
int msk[N2][N2];
bool used[N2][N2];
int k;
int m, n;

bool ok(int x, int y)
{
	return 0 <= x && x < m && 0 <= y && y < n; 
}

void setV(int x, int y, int val);

bool hasBit(int x, int i)
{
	return (x >> i) & 1;
}

void dfs(int x, int y)
{
	assert(a[y][x] != -1);
	used[y][x] = true;
	FOR (i, 0, k)
	{
		int dx = w[i].F;
		int dy = w[i].S;
		if (a[y][x] == 1)
		{
			if (hasBit(msk[y][x], i))
				setV(x - dx, y - dy, 0);
			else
				setV(x - dx, y - dy, 0);			
		}
		else
		{
			int nx = x + dx, ny = y + dy;
			if (ok(nx, ny) && !hasBit(msk[ny][nx], i))
				setV(nx, ny, 0);
		}
	}
}


void setV(int x, int y, int val)
{
	if (!ok(x, y)) return;
	assert(1 - a[y][x] != val);
	a[y][x] = val;
	if (!used[y][x])
		dfs(x, y);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	FOR (i, 0, N2) fill(a[i], a[i] + N2, -1);
	
	cin >> m >> n;
	cin >> k;
	FOR (i, 0, k)
	{
		cin >> w[i].F >> w[i].S;
		int sz;
		cin >> sz;
		FOR (j, 0, sz)
		{
			int x, y;
			cin >> x >> y;
			x--;
			y--;
			a[y][x] = 1;
			msk[y][x] |= 1 << i;
		}
	}
	int mxdx = 0, mndx = 0, mxdy = 0, mndy = 0;
	FOR (i, 0, k)
	{
		mxdx = max(mxdx, w[i].F);
		mndx = min(mndx, w[i].F);
		mxdy = max(mxdy, w[i].S);
		mndy = min(mndy, w[i].S);
	}
	FOR (y, 0, n)
	{
		FOR (x, 0, mxdx)
			if (a[y][x] == -1)
				a[y][x] = 0;
		FOR (x, m + mndx, m)
			if (a[y][x] == -1)
				a[y][x] = 0;
	}
	FOR (x, 0, m)
	{
		FOR (y, 0, mxdy)
			if (a[y][x] == -1)
				a[y][x] = 0;
		FOR (y, n + mndy, n)
			if (a[y][x] == -1)
				a[y][x] = 0;
	}

	FOR (y, 0, n)
	{
		FOR (x, 0, m)
		{
			if (!used[y][x] && a[y][x] != -1)
			{
				dfs(x, y);
			}
		}
	}
	string s = ".#";
	FOR (y, 0, n)
	{
		FOR (x, 0, m)
		{
			if (a[y][x] == -1)
				cout << '.';
			else
				cout << s[a[y][x]];
		}
		cout << '\n';
	}
	cout << '\n';
	FOR (y, 0, n)
	{
		FOR (x, 0, m)
		{
			if (a[y][x] == -1)
				cout << '#';
			else
				cout << s[a[y][x]];
		}
		cout << '\n';
	}
	cout << '\n';
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7844kb

input:

50000
(
(
))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()(
)
(
)
(((
(
(
(
(
(
()
(
)
(
)((())()((
)))))(
(
)
))
)()
(
)
)
)()(
(
(
()
(
)
(
)()((((())()))())(
(
(
)(
(
(
(()())())
)
)
(
(
(
)((())))((())))))))))((((()()))()))))))))((()())()))
)
)()
)
)
)
)
)
())(())))))()(()((()(())...

output:




result:

wrong output format Unexpected end of file - token expected