QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138522#4364. Ceiling FunctionPetroTarnavskyi#WA 7ms3496kbC++173.0kb2023-08-11 21:16:362023-08-11 21:16:40

Judging History

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

  • [2023-08-11 21:16:40]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3496kb
  • [2023-08-11 21:16:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

string numb[7];
int a[7][21];
int b[7][21];
vector<vector<string>> v;
char ans[7][21];
VI st = {0, 5, 12, 17};

bool ok(int t, int n)
{
	
	FOR (i, 0, n)
	{
		int h = t / 60;
		int m = t % 60;
		VI vec = {h / 10, h % 10, m / 10, m % 10};
		FOR (j, 0, 7)
		{
			FOR (k, 0, 21)
			{
				if (h < 10 && k < 5) continue;
				if (a[j][k] != 3) continue;
				int idx = upper_bound(ALL(st), k) - st.begin() - 1;
				if (k - st[idx] >= 4 || v[i][j][k] != numb[j][vec[idx] * 4 + k - st[idx]]) return false;
			}
		}
		t++;
		if (t >= 1440)
			t = 0;
	}
	return true;
	
}

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

	numb[0] = ".XX......XX..XX......XX..XX..XX..XX..XX.";
	numb[1] = "X..X...X...X...XX..XX...X......XX..XX..X";
	numb[2] = "X..X...X...X...XX..XX...X......XX..XX..X";
	numb[3] = ".........XX..XX..XX..XX..XX......XX..XX.";
	numb[4] = "X..X...XX......X...X...XX..X...XX..X...X";
	numb[5] = "X..X...XX......X...X...XX..X...XX..X...X";
	numb[6] = ".XX......XX..XX......XX..XX......XX..XX.";
	
	int n;
	cin >> n;
	v = vector<vector<string>>(n, vector<string>(7));
	FOR (i, 0, n)
	{
		FOR (j, 0, 7) 
		{
			cin >> v[i][j];
			FOR (k, 0, 21)
				a[j][k] |= (1 << (v[i][j][k] == 'X'));
		}
	}
	FOR (i, 0, 7)
	{
		FOR (j, 0, 21)
		{
			ans[i][j] = ".01W"[a[i][j]];
		}
	}
	int cnt = 0;
	FOR (T, 0, 1440)
	{
		if (ok(T, n))
		{
			cerr << T / 60 << ' ' << T % 60 << '\n';
			cnt++;
			int t = T;
			FOR (i, 0, n)
			{
				int h = t / 60;
				int m = t % 60;
				VI vec = {h / 10, h % 10, m / 10, m % 10};
				FOR (idx, 0, 4)
				{
					FOR (j, 0, 7)
					{
						FOR (k, st[idx], st[idx] + 4)
						{
							if (numb[j][32 + k - st[idx]] == '.') continue;
							b[j][k] += (numb[j][vec[idx] * 4 + k - st[idx]] == 'X');
						}
					}
				}
				t++;
				if (t >= 1440)
					t = 0;
			}
			FOR (j, 0, 7)
			{
				FOR (k, 0, 21)
				{
					if (b[j][k] == n && a[j][k] == 2)
						ans[j][k] = '?';
					if (b[j][k] == 0 && a[j][k] == 1)
						ans[j][k] = '?';
				}
			}
		}
	}
	
	if (cnt == 0)
	{
		cout << "impossible\n";
		return 0;
	}
	
	FOR (idx, 0, 4)
	{
		FOR (j, 0, 7)
		{
			FOR (k, st[idx], st[idx] + 4)
			{
				if (numb[j][32 + k - st[idx]] == '.') ans[j][k] = '.';
			}
		}
	}
	FOR (j, 0, 7)
	{
		ans[j][4] = '.';
		ans[j][9] = '.';
		ans[j][10] = '.';
		ans[j][11] = '.';
		ans[j][16] = '.';
	}
	
	ans[2][10] =  (a[2][10] != 2) ? '0' : '?';
	ans[4][10] =  (a[4][10] != 2) ? '0' : '?';
	
	FOR (i, 0, 7)
	{
		FOR (j, 0, 21) cout << ans[i][j];
		cout << '\n';
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 3496kb

input:

5 3
2 7 1
3 1 4
1 5 9
2 6 5
9 7 3

output:

.00...00.....00...00.
0..0.0..0...0..0.0..0
0..0.0..0.0.0..0.0..0
.??...??.....??...00.
0..0.0..0.0.0..0.0..0
0..0.0..0...0..0.0..0
.00...00.....00...00.

result:

wrong answer 1st lines differ - expected: '4', found: '.00...00.....00...00.'