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

Автор asim2005, 3 года назад, По-английски

https://codeforces.com/problemset/problem/1323/A

I have found something confusing in this problem.

This is the solution mohammadmahdi.hamidzadeh wrote.

include <bits/stdc++.h>

using namespace std;

int main(){ int t;cin>>t;while(t--){ int n,a=0,x;cin>>n; for(int i=1;i<=n;i++){ cin>>x; if(x%2==0)a=i; } if(a)cout<<1<<endl<<a<<endl; else{ if(n==1)cout<<-1<<endl; else cout<<2<<endl<<1<<" "<<2<<endl; } } }

I changed a little bit in this code.

include <bits/stdc++.h>

using namespace std;

int main(){ int t; cin>>t; while(t--){ int n,a = 0,x; cin>>n; for(int i=1;i<=n;i++){ cin>>x; if(x%2==0)a=i; } if(a)cout<<1<<endl<<a<<endl; else{ if(n==1)cout<<-1<<endl; else cout<<2<<endl<<1<<" "<<2<<endl; } } return 0; } // This is my code

But after this change, the outputs I am getting are wrong. I cannot understand this.

My question is : Where did I messed up?

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

»
3 года назад, # |
Rev. 2   Проголосовать: нравится +18 Проголосовать: не нравится

Try to use codeforces markup to insert code in the post.

Hope that helps you explain your problem properly.

»
3 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Next time either give links to submission, or use proper formatting to display code.