QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#726402#2923. Code Guessingzeyu#AC ✓1ms3860kbC++232.1kb2024-11-08 23:50:352024-11-08 23:50:35

Judging History

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

  • [2024-11-08 23:50:35]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3860kb
  • [2024-11-08 23:50:35]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pl pair<ll, ll>
#define pi pair<int, int>
#define minpq priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;

#if 1
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '['; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "]";}
void _print() {cerr << endl << flush;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "*["<<__LINE__<<"]\t"<< #x << " = "; _print(x)
#endif

const ll mod = 1e9 + 7;

template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll gcd(ll a, ll b) {if(b == 0){return a;} return gcd(b, a % b);}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int p, q; cin >> p >> q;
	string s; cin >> s;
	vector<pi> ans;
	for (int i = 1; i <= 9; i ++){
		for (int j = i + 1; j <= 9; j ++){
			vector<int> cur = {i, j, p, q};
			sort(cur.begin(), cur.end());
			string t = "";
			for (int k = 0; k < 4; k ++){
				if (cur[k] == i || cur[k] == j) t.push_back('B');
				else t.push_back('A');
			}
			if (t == s) ans.push_back({i, j});
		}
	}
	if (ans.size() == 1) cout << ans[0].fi << ' ' << ans[0].se;
	else cout << -1;
}

详细

Test #1:

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

input:

3 4
BBAA

output:

1 2

result:

ok single line: '1 2'

Test #2:

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

input:

3 7
BBAA

output:

1 2

result:

ok single line: '1 2'

Test #3:

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

input:

3 9
BBAA

output:

1 2

result:

ok single line: '1 2'

Test #4:

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

input:

5 6
BBAA

output:

-1

result:

ok single line: '-1'

Test #5:

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

input:

6 7
AABB

output:

8 9

result:

ok single line: '8 9'

Test #6:

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

input:

3 7
AABB

output:

8 9

result:

ok single line: '8 9'

Test #7:

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

input:

1 7
AABB

output:

8 9

result:

ok single line: '8 9'

Test #8:

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

input:

4 5
AABB

output:

-1

result:

ok single line: '-1'

Test #9:

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

input:

1 4
ABBA

output:

2 3

result:

ok single line: '2 3'

Test #10:

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

input:

3 6
ABBA

output:

4 5

result:

ok single line: '4 5'

Test #11:

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

input:

4 7
ABBA

output:

5 6

result:

ok single line: '5 6'

Test #12:

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

input:

5 9
ABBA

output:

-1

result:

ok single line: '-1'

Test #13:

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

input:

1 5
ABBA

output:

-1

result:

ok single line: '-1'

Test #14:

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

input:

2 7
ABBA

output:

-1

result:

ok single line: '-1'

Test #15:

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

input:

1 9
ABBA

output:

-1

result:

ok single line: '-1'

Test #16:

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

input:

2 8
BAAB

output:

1 9

result:

ok single line: '1 9'

Test #17:

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

input:

3 8
BAAB

output:

-1

result:

ok single line: '-1'

Test #18:

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

input:

2 6
BAAB

output:

-1

result:

ok single line: '-1'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

4 5
BAAB

output:

-1

result:

ok single line: '-1'

Test #20:

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

input:

6 8
ABAB

output:

7 9

result:

ok single line: '7 9'

Test #21:

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

input:

4 8
ABAB

output:

-1

result:

ok single line: '-1'

Test #22:

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

input:

3 7
ABAB

output:

-1

result:

ok single line: '-1'

Test #23:

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

input:

5 7
ABAB

output:

-1

result:

ok single line: '-1'

Test #24:

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

input:

1 3
ABAB

output:

-1

result:

ok single line: '-1'

Test #25:

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

input:

2 4
BABA

output:

1 3

result:

ok single line: '1 3'

Test #26:

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

input:

2 5
BABA

output:

-1

result:

ok single line: '-1'

Test #27:

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

input:

3 5
BABA

output:

-1

result:

ok single line: '-1'

Test #28:

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

input:

7 9
BABA

output:

-1

result:

ok single line: '-1'

Test #29:

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

input:

6 9
ABBA

output:

7 8

result:

ok single line: '7 8'

Test #30:

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

input:

2 5
BAAB

output:

-1

result:

ok single line: '-1'