質問編集履歴

1

検証を行いました

2021/01/09 07:34

投稿

nonoilaoziso
nonoilaoziso

スコア19

test CHANGED
@@ -1 +1 @@
1
- Atcoder abc165_c について
1
+ Atcoder abc165_c 期待する答えが出力されません
test CHANGED
@@ -1,4 +1,4 @@
1
- 以下のコードで Atcoder abc165_c (https://atcoder.jp/contests/abc165/tasks/abc165_c)の入力例を試したのですが、すべてで 0 が返ってきます。どなたか理由を教えていただけたら嬉しいです。
1
+ 以下のコードで Atcoder abc165_c (https://atcoder.jp/contests/abc165/tasks/abc165_c)の入力例を試したのですが、すべてで 0 が返ってきます。関数 func 内の debug のところで確認すると、ひたすら空の文字列が出力されました。どなたか理由を教えていただけたら嬉しいです。
2
2
 
3
3
 
4
4
 
@@ -40,15 +40,21 @@
40
40
 
41
41
 
42
42
 
43
- void func(string s) {
43
+ void func(string A) {
44
44
 
45
- if (sz(s) == N) {
45
+ if (sz(A) == N) {
46
+
47
+ /* debug
48
+
49
+ cout << A << "\n";
50
+
51
+ */
46
52
 
47
53
  int score = 0;
48
54
 
49
55
  rep(i, Q) {
50
56
 
51
- if (s[b[i] - 1] - s[a[i] - 1] == c[i]) score += d[i];
57
+ if (A[b[i] - 1] - A[a[i] - 1] == c[i]) score += d[i];
52
58
 
53
59
  }
54
60
 
@@ -60,15 +66,15 @@
60
66
 
61
67
  int last = 1;
62
68
 
63
- if (sz(s) >= 1) last = s[sz(s) - 1];
69
+ if (sz(A) >= 1) last = A[sz(A) - 1];
64
70
 
65
71
  rep2(i, last, M + 1) {
66
72
 
67
- string ns = s;
73
+ string nA = A;
68
74
 
69
- ns += ('0' + i);
75
+ nA += ('0' + i);
70
76
 
71
- func(ns);
77
+ func(nA);
72
78
 
73
79
  }
74
80
 
@@ -88,11 +94,11 @@
88
94
 
89
95
  rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
90
96
 
91
- string s;
97
+ string A = "";
92
98
 
93
99
 
94
100
 
95
- func(s);
101
+ func(A);
96
102
 
97
103
 
98
104