# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82577 | 2018-10-31T14:12:10 Z | Leonardo_Paes | Usmjeri (COCI17_usmjeri) | C++11 | 638 ms | 40604 KB |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; typedef pair<int,int> pii; #define MAXN 300100 int vet[MAXN], pre[MAXN]; int main(){ int n, m; cin >> n >> m; // inutil pro caso 20% for(int i=1; i<n; i++){ int a, b; cin >> a >> b; } vector<pii> v; for(int i=1; i<=m; i++){ int x, y; cin >> x >> y; if(x>y)swap(x,y); vet[x]=y; pre[x]++; pre[y+1]--; } long long ans=1; for(int i=1; i<=n; i++){ pre[i]+=pre[i-1]; if(pre[i]==0){ ans=(ans*2)%mod; } } int ini=0, fim=0; for(int i=1; i<=n; i++){ if(i>=fim and fim!=0){ v.push_back({ini,fim}); ini=0; fim=0; } if(vet[i]!=0){ if(ini==0){ ini=i; } fim=vet[i]; } } for(int i=0; i<v.size(); i++){ ans = (ans*2)%mod; } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 229 ms | 4212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 457 ms | 12004 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 12004 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 12004 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 12004 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 12004 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 476 ms | 20792 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 542 ms | 28636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 489 ms | 35812 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 638 ms | 40604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |