Блог пользователя Frenzy_Love

Автор Frenzy_Love, история, 7 часов назад, По-английски

1408A Circle Coloring

This exercise went accepted with the following code:

include

include

using namespace std;

define pb push_back

int main() { int query; cin >> query; while(query--){ int n; cin >> n;

vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];

    vector<int> v(n); 


    v[0] = a[0];


    for(int i = 1; i < n; i++) {
        if(a[i] != v[i-1] && (i != n-1 || a[i] != v[0])) v[i] = a[i];
        else if(b[i] != v[i-1] && (i != n-1 || b[i] != v[0])) v[i] = b[i];
        else v[i] = c[i];
    }


    for(int i = 0; i < n; i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

return 0;

} BUT !!! it can be hacked with any test case where choosing a different from previous integer which will match a equality of elements in the next iteration, for example: a[5] = {2, 2, 3, 4, 5}; b[5] = {3, 2, 8, 5, 5}; c[5] = {9, 2, 4, 7, 5};

Then, why an exercise would be "Accepted" with poor code when the statement itself induce to a more complex written code ??? // If it is done on purpose for the competitive participants to break into "hacking" one another still doesn't make sense for the actual solo writer, it's disappointing to face "higher" work passed onto as if the exercise wasn't actually been thought thoroughly, that implies a low standard acceptance on exercise making.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -10
  • Проголосовать: не нравится

Автор Frenzy_Love, история, 10 месяцев назад, По-английски

/* for l = 8, r = 26 */

include

include

include

include

using namespace std; using L = long; using LL = long long;

int main() {

int t;
cin >> t;

while (t--) {

    LL l, r;
    cin >> l >> r;

     LL res = (r >= 2 * l) ? (r - 1) / 2 : (r - l);

    cout << res << endl;
 }

return 0;

} /* how it is so that the answer is not 18 but 12!??? thanks, */

Полный текст и комментарии »

  • Проголосовать: нравится
  • -14
  • Проголосовать: не нравится