제출 #953452

#제출 시각아이디문제언어결과실행 시간메모리
953452vjudge1경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
using namespace std;
using ii = pair<int,int>; using ll = long long; using ull = unsigned long long;
using vi = vector<int>;
void valid(int in){cout<<((in)?"YES\n":"NO\n");return;}
const int N = 2e5 + 7, mod = 1e9 +7;
int fac[N];
void criba(){
    fo(i,N)fac[i] = i;
    fore(i,2,N){
        if(fac[i] == i){
            for(int j = i+i; j <N; j+=i) fac[j] = i;
        }
    }
}
map<int,int> facto(int n, map<int,int> res = {}){
    while(n!=1){
        res[fac[n]]++;n/=fac[n];
    }return res;
}
ll fpow(ll a , ll b, ll res = 1 ){
    while(b){
        if(b&1)res = (res*a)%mod;
        a = (a*a)%mod;b>>=1;
    }return res;
}
void test_case(){
    int n,q; cin >> n >> q;
    vector<map<int,int>> arr;
    fo(i,n){
        int a; cin >> a;
        arr.pb(facto(a));
    }
    map<int, multiset<int>> mn;
    fo(i,n){
        auto wt =arr[i];
        for(auto[k,v] : wt)mn[k].insert(v);
    }ll ans = 1;
    for(auto [k,v] : mn){
        if(v.size()==n) ans = (ans * fpow(k, *v.begin()))%mod;
    }cout << ans << endl;
    while(q--){
        int idx, x; cin >> idx >> x; idx--;
        auto wt = facto(x), &act = arr[idx];
        for(auto [k,v] : wt){
            if(mn[k].size() == n) ans = (ans* fpow(fpow(k, *mn[k].begin()), mod-2))%mod;
            if(act[k] != 0 )mn[k].erase(act[k]);
            mn[k].insert(act[k]+v);
            if(mn[k].size() == n)ans = (ans * fpow(k, *mn[k].begin()))%mod;
            act[k] += v;
        }
        for(auto [k,v] : mn){
            cout << k << endl;
            for(auto xd : v)cout << xd << " "; cout << endl;
        }cout << ans << endl;
    }
}   
int main(){cin.tie(0)->sync_with_stdio(0);
    int t;t=1;criba();
    while(t--)test_case();
}

컴파일 시 표준 에러 (stderr) 메시지

race.cpp: In function 'void test_case()':
race.cpp:54:20: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |         if(v.size()==n) ans = (ans * fpow(k, *v.begin()))%mod;
      |            ~~~~~~~~^~~
race.cpp:60:29: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |             if(mn[k].size() == n) ans = (ans* fpow(fpow(k, *mn[k].begin()), mod-2))%mod;
      |                ~~~~~~~~~~~~~^~~~
race.cpp:63:29: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   63 |             if(mn[k].size() == n)ans = (ans * fpow(k, *mn[k].begin()))%mod;
      |                ~~~~~~~~~~~~~^~~~
race.cpp:68:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   68 |             for(auto xd : v)cout << xd << " "; cout << endl;
      |             ^~~
race.cpp:68:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   68 |             for(auto xd : v)cout << xd << " "; cout << endl;
      |                                                ^~~~
/usr/bin/ld: /tmp/cczdLjP4.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccYliyi6.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccYliyi6.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status