QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#390103#5420. InscryptionVeryAmazedCompile Error//C++141.7kb2024-04-15 04:03:222024-04-15 04:03:22

Judging History

你现在查看的是最新测评结果

  • [2024-04-15 04:03:22]
  • 评测
  • [2024-04-15 04:03:22]
  • 提交

answer

#include <bits/stdc++.h>

#define pb push_back
#define pii pair<int, int>
#define f first
#define s second

using namespace std;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int t; cin >> t;
	while (t--){
	  int n;
	  cin >> n;
	  int total = 1;
	  vector<int> ones;
	  vector<int> zeros;
	  vector<int> negs;
	  for(int i = 0; i < n; i++){
	    int a;
	    cin >> a;
	    if(a == 1){
	      total++;
	      ones.pb(i);
	    }else if(a == 0){
	      zeros.pb(i);
	    }else{
	      negs.pb(i);
	    }
	  }
	  vector<pii> vec;
	  int ind = 0;
	  for(int i = 0; i < ones.size(); i++){
	    while(ind < negs.size() && negs[ind] <= ones[i]){
	      ind++;
	    }
	    if(ind == negs.size()) break;
	    ones[i] = -1;
	    negs[ind] = -1;
	  }
	  int givens = 0;
	  int combines = 0;
	  for(int i = 0; i < ones.size(); i++){
	    if(ones[i] == -1) continue;
	    vec.pb({ones[i], 1});
	  }
	  for(int i = 0; i < negs.size(); i++){
	    if(negs[i] == -1) continue;
	    vec.pb({negs[i], -1});
	    combines++;
	  }
	  for(int i = 0; i < zeros.size(); i++){
	    vec.pb({zeros[i], 0});
	  }
	  sort(vec.begin(), vec.end());
	  /*
	  for(int i = 0; i < vec.size(); i++){
	    cout << vec[i].s << " ";
	  }
	  cout << "\n";
	  */
	  bool works = true;
	  for(int i = 0; i < vec.size(); i++){
	    if(vec[i].s == 1) givens++;
	    else if(vec[i].s == -1){
	      givens--;
	      combines--;
	    }else{
	      if(givens > combines) givens--;
	      else{
		givens++;
		total++;
	      }
	    }
	    if(givens < 0) works = false;
	  }
	  if(works){
	    int g = __gcd(total, givens+1);
	    cout << total/g << " " << (givens+1)/g << "\n";
	  }else{
	    cout << -1 << "\n";
	  }
	}
	cout << endl;
}
 

詳細信息

answer.code:87:1: error: extended character   is not valid in an identifier
   87 |  
      | ^
answer.code:87:1: error: ‘ ’ does not name a type
   87 |  
      | ^