QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#519688#4682. Pipe StreamPetroTarnavskyiWA 0ms3644kbC++231.2kb2024-08-14 23:52:512024-08-14 23:52:51

Judging History

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

  • [2024-08-14 23:52:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3644kb
  • [2024-08-14 23:52:51]
  • 提交

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;



void solve()
{
	int l, v1, v2, t, s;
	cin >> l >> v1 >> v2 >> t >> s;
	
	l /= s;
		
	int cnt = 0;
	int inter = 1;
	
	set<PII> used;
	while(v2 - v1 > t * inter)
	{
		if(cnt > 100)
		{
			if(used.count(MP(inter, v2)))
			{
				cout << l << "," << v1 << "," << v2 << "," << t << "," << s << "\n";
				exit(0);
			}
			used.insert(MP(inter, v2));

			if(cnt >= 200)
			{
				cout << "impossible\n";
				return;
			}
		}
		int v = l / (cnt + 1);
		if(v + t < v2)
		{
			int nprom = (v2 - v - 1) / t;
			if(inter < nprom)
			{
				cout << "impossible\n";
				return;
			}
			v2 -= t * nprom;
			inter = 2 * (inter - nprom);
		}
		else
			inter = 2 * inter;
		cnt++;
	}
	cout << cnt << "\n";
}


int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	
	int t;
	cin >> t;
	while(t--)
		solve();
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1000 1 30 1 1
60 2 10 2 5
59 2 10 2 5

output:

5
3
impossible

result:

ok 3 lines

Test #2:

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

input:

100
1 1 2 1 1
1 1 3 1 1
2 1 3 1 1
3 1 4 1 1
4 1 4 1 1
100000 1 1000000 1 1
100000 1 9 1 1
100000 1 9454 1 1
100000 1 9455 1 1
500832 1 40181 1 1
500832 1 40182 1 1
524288 1 41871 1 1
524288 1 41872 1 1
930168 1 70677 1 1
930168 1 70678 1 1
930169 1 70677 1 1
930169 1 70678 1 1
930170 1 70677 1 1
930...

output:

0
impossible
1
impossible
2
impossible
3
24
impossible
45
impossible
32
impossible
46
impossible
46
impossible
46
impossible
45
impossible
45
impossible
impossible
3
3
4
impossible
0
0
impossible
17
15
16
2
2
15
15
14
1
1
0
0
impossible
16
impossible
0
1
2
2
28
29
impossible
29
impossible
0
1
imposs...

result:

ok 100 lines

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3576kb

input:

40
1000 1 30 1 1
60 2 10 2 5
59 2 10 2 5
1000000 1 80235 2 1
1000000 1 80236 2 1
1000000 1 80237 2 1
1000000 1 80238 2 1
1000000 1 80239 2 1
1000000 1 80240 2 1
1000000 1 80241 2 1
1000000 1 80242 2 1
1000000 1 80243 2 1
1000000 1 75361 1 1
1000000 1 75362 1 1
1000000 1 75363 1 1
1000000 1 75364 1 1...

output:

5
3
impossible
25
25
25
26
26
26
27
29
impossible
26
26
26
27
27
28
29
impossible
impossible
28
500000,1,500002,499998,2

result:

wrong answer 23rd lines differ - expected: 'impossible', found: '500000,1,500002,499998,2'