fork download
  1. /*
  2.   Cred : SunnyYeahBoi
  3.   It's my last chance (⌐■_■)
  4.   Problem :
  5. */
  6.  
  7. #include<bits/stdc++.h>
  8.  
  9. using namespace std;
  10.  
  11. #define int long long
  12. #define double long double
  13. #define endl "\n"
  14. #define NAME "a"
  15.  
  16. const int MAXN = 1e6 + 5;
  17. const int inf = 1e18;
  18. const int MOD = 1e9 + 7;
  19.  
  20. void FileInput(){
  21. if(fopen(NAME".inp" , "r") == NULL)
  22. freopen(NAME".inp" , "w" , stdout);
  23. freopen(NAME".inp" , "r" , stdin);
  24. freopen(NAME".out" , "w" , stdout);
  25. }
  26.  
  27. int n;
  28. int a[MAXN] , f[MAXN];
  29. int q;
  30.  
  31. void solve(){
  32. cin >> n;
  33. for(int i = 1 ; i <= n ; i++){
  34. cin >> a[i];
  35. }
  36.  
  37. cin >> q;
  38. while(q--){
  39. int l , r;
  40. cin >> l >> r;
  41. f[l]++;
  42. f[r + 1]--;
  43. }
  44.  
  45. for(int i = 1 ; i <= n ; i++){
  46. f[i] += f[i - 1];
  47. }
  48.  
  49. for (int i = 1 ; i <= n ; i++){
  50. if(f[i] % 2 == 0)
  51. cout << a[i] << " ";
  52. else cout << -a[i] << " ";
  53. }
  54. }
  55.  
  56. int32_t main(){
  57. FileInput();
  58. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  59. int t = 1;
  60. // cin >> t;
  61. while(t--)
  62. solve();
  63. return 0;
  64. }
  65.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty