結果

問題 No.1226 I hate Robot Arms
ユーザー pengin_2000pengin_2000
提出日時 2020-09-12 00:34:09
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 2,144 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 32,544 KB
実行使用メモリ 7,864 KB
最終ジャッジ日時 2023-08-30 11:16:24
合計ジャッジ時間 28,232 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,328 KB
testcase_01 AC 1 ms
4,436 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<math.h>
int main()
{
	int n, q;
	scanf("%d %d", &n, &q);
	int i, j, k;
	int t[100005], ind[100005];
	double nx[100005];
	for (i = 0; i < q; i++)
	{
		scanf("%d %d", &t[i], &ind[i]);
		if (t[i] < 2)
		{
			scanf("%lf", &nx[i]);
			ind[i]--;
		}
	}
	double length[100005], theta[100005], st[100005];
	for (i = 0; i < n; i++)
	{
		length[i] = 1.0;
		theta[i] = 0.0;
		st[i] = 0.0;
	}
	int sq = 0;
	while (sq * sq < n)
		sq++;
	double x[100005], y[100005];
	x[0] = y[0] = 0.0;
	for (i = 0; i < n; i++)
	{
		x[i + 1] = x[i] + length[i];
		y[i + 1] = 0;
	}
	double xx, yy, ds, r, s, dx, dy, dl;
	for (i = 0; i < q; i++)
	{
		if (t[i] == 0)
		{
			ds = nx[i] * acos(-1) / 180.0 - theta[ind[i]];
			theta[ind[i]] = nx[i] * acos(-1) / 180.0;
			if (ind[i] > 0)
				st[ind[i]] = st[ind[i] - 1] + theta[ind[i]];
			else
				st[0] = theta[0];
			j = 0;
			while (j + sq <= ind[i])
				j += sq;
			k = j + sq;
			for (; j <= k; j++)
			{
				x[j + 1] = x[j] + length[j] * cos(st[j]);
				y[j + 1] = y[j] + length[j] * sin(st[j]);
				st[j + 1] = st[j] + theta[j + 1];
			}
			for (j = k + sq; j <= n; j += sq)
			{
				dx = x[j] - x[ind[i]];
				dy = y[j] - y[ind[i]];
				r = sqrt(dx * dx + dy * dy);
				s = acos(dx / r);
				if (dy < 0)
					s *= -1;
				s += ds;
				x[j] = x[ind[i]] + r * cos(s);
				y[j] = y[ind[i]] + r * sin(s);
				st[j] += ds;
			}
		}
		else if (t[i] == 1)
		{
			dl = nx[i] - length[ind[i]];
			length[ind[i]] = nx[i];
			j = 0;
			while (j + sq <= ind[i])
				j += sq;
			k = j + sq;
			for (; j <= k; j++)
			{
				x[j + 1] = x[j] + length[j] * cos(st[j]);
				y[j + 1] = y[j] + length[j] * sin(st[j]);
				st[j + 1] = st[j] + theta[j + 1];
			}
			dx = dl * cos(st[ind[i]]);
			dy = dl * sin(st[ind[i]]);
			for (j = k + sq; j <= n; j += sq)
			{
				x[j] += dx;
				y[j] += dy;
			}
		}
		else
		{
			j = 0;
			while (j + sq <= ind[i])
				j += sq;
			k = j + sq;
			for (; j < k; j++)
			{
				x[j + 1] = x[j] + length[j] * cos(st[j]);
				y[j + 1] = y[j] + length[j] * sin(st[j]);
				st[j + 1] = st[j] + theta[j + 1];
			}
			printf("%.20lf %.20lf\n", x[ind[i]], y[ind[i]]);
		}
	}
	return 0;
}
0