Submission #705009

# Submission time Handle Problem Language Result Execution time Memory
705009 2023-03-03T07:56:51 Z Paul_Liao_1457 Superpozicija (COCI22_superpozicija) C++17
0 / 110
179 ms 480 KB
//記得跳題
//#pragma GCC optimize("O4,unroll_loops")
//#pragma GCC target("avx2")
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<tuple>
#include<random>
 
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define INF (ll)(2e18)
#define F first
#define S second
#define endl "\n"
#define AC ios::sync_with_stdio(0);
 
using namespace std;
 
string s;
int id[200005], a[200005], b[200005], suf[200005], ans[200005], who[200005];
 
void solve() {
  int n; cin >> n;
  cin >> s;
  FOR (i, 0, n) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  
  FOR (m, 0, 1<<n) {
    string tmp = s;
    FOR (i, 0, n) {
      if ((m>>i) & 1) {
        tmp[a[i]] = s[a[i]];
        tmp[b[i]] = '?';
      } else {
        tmp[a[i]] = '?';
        tmp[b[i]] = s[b[i]];
      }
    }
    //cout << "tmp = " << tmp << endl;
    bool ok = 1;
    int sum = 0;
    FOR (i, 0, tmp.size()) {
      if (tmp[i] != '?') {
        if (tmp[i] == '(') sum++;
        else if(tmp[i] == ')') sum--;
        if (sum < 0){
          ok = 0;
          break;
        }
      }
    }
    if (ok && sum == 0) {
      FOR (i, 0, n) {
        if ((m>>i) & 1) {
          if (i != n-1) cout << 0 << " ";
          else cout << 0 << endl;
        } else {
          if (i != n-1) cout << 1 << " ";
          else cout << 1 << endl;
        }
      }
      //cout << endl;
      return;
    }
  }
  cout << -1 << endl; return;
 
}
 
signed main(){
  AC;
  int t; cin >> t;
  while (t--) {
    solve();
  }
}
 
/*
 vector<pair<int, int> > e[200005];
 vector<pair<int, int> > ans;
 
 void dfs(int now, int f,int up){
   if (up != -1) {
     ans.pb({now, up});
   }
   for (auto i:e[now]) if (i.F != f) {
     dfs(i.F, now, i.S);
   }
 }
 
 signed main(){
   AC;
   int n, m; cin >> n >> m;
   FOR (i, 0, m) {
     int a, b; cin >> a >> b;
     e[a].pb({b, 0});
     e[b].pb({a, 1});
   }
   dfs(1, 0, -1);
   cout << ans.size() << endl;
   for (auto i:ans) {
     cout << i.F << " " << i.S << endl;
   }
 }
 
 
 */

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:23:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 | #define FOR(i,a,b) for(int i=a;i<b;i++)
......
   59 |     FOR (i, 0, tmp.size()) {
      |          ~~~~~~~~~~~~~~~~        
Main.cpp:59:5: note: in expansion of macro 'FOR'
   59 |     FOR (i, 0, tmp.size()) {
      |     ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 179 ms 480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 179 ms 480 KB Output isn't correct
2 Halted 0 ms 0 KB -