蒟蒻求助!WA了,自己测得样例都过了

CF1B Spreadsheets

@[sz_jinzikai](/user/592476) 给你CF数据自己调 1 A1 答案是R1C1 你的是RA1C0
by 小明小红 @ 2023-02-25 08:51:00


@[小明小红](/user/368346) 感谢
by sz_jinzikai @ 2023-02-25 12:19:20


@[小明小红](/user/368346) 现在发现问题了,是每次judge时i没初始化0,但是还是WA了,能帮忙看一下吗? ```cpp //洛谷CF1B # include <bits/stdc++.h> # define ffor(i,name) \ for (auto i = name.end (); i != name.end (); i ++) # define iter(type) \ type :: iterator using namespace std; typedef long long ll; typedef pair <int, int> pii; int n, power, sum, i, j, m, ans, t; string a; bool judge () { i = 0; while (i < m && a[i] > '9') i ++; // cout << j << ' ' << i << '\n'; j = i; while (i < m && a[i] < 'A') i ++; return i > m - 2; } void print (int x) { if (x > 26) print (x / 26); if (x % 26) cout << (char) (x % 26 - 1 + 'A'); else cout << 'Z'; return ; } int main () { ios::sync_with_stdio (0); cin.tie (0); cout.tie (0); cin >> n; while (n --) { cin >> a; m = a.size (); ans = 0; if (judge ()) { power = 1; for (i = j - 1; i >= 0; i --) ans += (a[i] - 'A' + 1) * power, power *= 26; // cout << j << '\n'; cout << 'R'; for (i = j; i < m; i ++) cout << a[i]; cout << 'C' << ans; } else { while (a[j] < 'C') j ++; for (i = j + 1; i < m; i ++) ans = ans * 10 + a[i] - '0'; // cout << ans << '\n'; print (ans); for (i = 1; i < j; i ++) cout << a[i]; } cout << '\n'; } return 0; } ```
by sz_jinzikai @ 2023-02-25 14:02:50


@[sz_jinzikai](/user/592476) 看私信
by 小明小红 @ 2023-02-25 14:13:06


|